Jump to content

What is the best way to echo?


kristen

Recommended Posts

kristen: it depends on you, 3 of them will work, but the third once can save you some times.

for my own preference, i use the second one.

 

bubblebla: call data from table? i assume you mean from database's table..

not sure if my explanation is correct,

 

normally, when u make a query, you will have something like..

$row = mysql_fetch_array($query);

 

if you don't know the column name, you can echo the data like $row[0], $row[1]....

if you know the column name, you can echo the data like $row['id'], $row['name']...

if you use extract($row), you can straight away use it according to the column name, $id, $name...

 

cheers...

Link to comment
Share on other sites

Both the second and third options rely on the short_open_tag setting being turned on in your php.ini

 

I prefer the first - a couple extra characters is worth the fact that it will definitely work. It's also worth the fact that we get syntax highlighting on the forum with those tags.

Link to comment
Share on other sites

I will second GingerRobot and thorpe.

 

The only time you should use the second or third option is if the script is designed for one server, and you know it will always have short_open_tag on.

 

If, for any reason, it gets turn off, anything using <? or <?= to begin parsing PHP will NOT be parsed. This can reveal sensitive variable information, vulnerabilities in your code, or simply allow someone to copy your source.

 

In my opinion, the guarantee that PHP will parse is worth the few extra characters.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.