CodeIgniter Forums
UserGuide notation - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: UserGuide notation (/showthread.php?tid=66047)



UserGuide notation - twpmarketing - 08-28-2016

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.


RE: UserGuide notation - ciadmin - 08-28-2016

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


RE: UserGuide notation - twpmarketing - 08-28-2016

Ah, thank you!


RE: UserGuide notation - MackieeE - 08-31-2016

(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!