« Previous entry | Next entry » Browse > Snippets

Skip to comments (10) PHP echo
Posted by ckuron on Oct 31 2005 @ 12:50  :: 1769 unique visits

Yesterday I've learned something new in PHP.

CODE: PHP
<div>
<?= $row['field'] ?>
</div>


is equivalent to

CODE: PHP
<div>
<? echo $row['field'] ?>
</div>


Obviously I know that many people know that, but it could be useful for the minority which don't :P

10 comments posted so far
Add your own »

1. On Oct 31 2005 @ 13:45 guest wrote:

It's not equivalent in its readability.

2. On Oct 31 2005 @ 17:48 Erik wrote:

I use
CODE: PHP
<?=$row['field']?>

all the time.

3. On Nov 01 2005 @ 08:02 TheJohnDoe2005 wrote:

classic post...remind me of the days when i was learning PHP and ASP...hahah

4. On Nov 02 2005 @ 05:21 guest wrote:

I use <?php eval("echo("what do you want to write")"); ?>

5. On Nov 05 2005 @ 08:24 guest wrote:

Hmmz, I guess I belonged to the minority...

6. On Nov 08 2005 @ 15:21 guest wrote:

CODE: PHP
<?php eval("echo("what do you want to write")"); ?>


Why on earth do you use that? Ive investigated before and i cant see any draw backs to using the
CODE: PHP
<??>
method. When flipping in and out of html, it makes it so much easier to read. For any one who doesnt know, you can also do this:
CODE: PHP
<? if ($torrents == 'happiness') { ?>
      put your html here
<? } ?>

If anyone knows of any reasons why my practise is bad practise, please say so!

7. On Nov 14 2005 @ 08:26 dustin wrote:

yeah, personally ternaries are my favorite php shortcuts.

8. On Nov 21 2005 @ 17:30 guest wrote:

I use long PHP openings tags.
CODE: PHP
<?php ?>

instead of:
CODE: PHP
<? ?>

Then it will also work on servers which has short tags disabled.

To echo something i use:
CODE: PHP
<?php
   echo "jada";
?>

9. On Mar 17 2006 @ 13:58 kaos wrote:

>>
CODE: PHP
<?php eval("echo("what do you want to write")"); ?>

>> "Why on earth do you use that?"

come on
he is just joking
he could even write sumtin like this:
<?php eval("eval(\"eval(\"eval(\"[and so on...]\");\");\");"); ?>

and by the way his code contains some errors, he should've escaped the double quotes inside echo

Add a new comment

Name:
Password: (leave empty for anonymous comment)
 
View formatting tags Comment: