Welcome Guest, Not a member yet? Register   Sign In
UserGuide notation
#1

Reading this page in the UG:

https://bcit-ci.github.io/CodeIgniter4/general/views.html

I note that there is a code segment which shows something I am NOT familiar with;  a variable ($data) is assigned using notation which might be an array, but I've never seen this notation:


Code:
class Page extends \CodeIgniter\Controller
{
       public function index()
       {
               $data = [
                       'page_title' => 'Your title'
               ];

               echo view('header');
               echo view('menu');
               echo view('content', $data);
               echo view('footer');
       }
}


Should this actually read:

Code:
...
$data = array('page_title' => 'Your title');
...


Or is this using a "shorthand" php array declaration?
Yes, I have looked at the PHP 7 documentation, but do not find this type of assignment for an array.
CI 3.1 Kubuntu 19.04 Apache 5.x  Mysql 5.x PHP 5.x PHP 7.x
Remember: Obfuscation is a bad thing.
Clarity is desirable over Brevity every time.
Reply
#2

Since PHP 5.4 ... shorthand array notation Smile
http://php.net/manual/en/language.types.array.php
Reply
#3

Ah, thank you!
CI 3.1 Kubuntu 19.04 Apache 5.x  Mysql 5.x PHP 5.x PHP 7.x
Remember: Obfuscation is a bad thing.
Clarity is desirable over Brevity every time.
Reply
#4

(08-28-2016, 01:30 PM)twpmarketing Wrote: Ah, thank you!

This and alot of new notation in PHP 7 that looks alien to PHP < 5.4!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB