Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

how to echo a variable with brackets

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

how to echo a variable with brackets

Postby inoob » Fri Apr 19, 2013 4:39 pm

Certainly this would be correct:

<?=$variable?>

But would this be correct as well:

<?=$variable['fldID'];?>

It's not displaying correctly.
inoob
New php-forum User
New php-forum User
 
Posts: 31
Joined: Tue Nov 06, 2012 12:20 pm

Re: how to echo a variable with brackets

Postby johnj » Fri Apr 19, 2013 8:44 pm

Using short tag is not a good practice because short tags (<? ?>) can be disabled through the php.ini file. Better write your code as <?php echo $variable['fldId'] ?>
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: how to echo a variable with brackets

Postby inoob » Sat Apr 20, 2013 4:06 am

Your right. I just read it has conflictions especially with XML.
inoob
New php-forum User
New php-forum User
 
Posts: 31
Joined: Tue Nov 06, 2012 12:20 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yahoo [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.