how to echo a variable with brackets

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

inoob
New php-forum User
New php-forum User
Posts: 31
Joined: Tue Nov 06, 2012 12:20 pm

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.

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 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'] ?>

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 inoob » Sat Apr 20, 2013 4:06 am

Your right. I just read it has conflictions especially with XML.


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 2 guests