PDA

View Full Version : <?=$stuff?>


IKinsler
07-12-2002, 08:12 PM
What do you think of the ability to print a variable just by using the = sign and the variable name inside the PHP tags?

IKinsler
07-12-2002, 08:39 PM
Who wouldn't like the option! :p

Ökii
07-12-2002, 08:52 PM
The only downfall as far as I'm aware of using <?= as oposed to
<?php echo is... you'll not get a good validation return toward
XHTML compliance.

If you're using a nice modern version of PHP it does cut down on
the ol' filesize by 7 bytes :D

IKinsler
07-12-2002, 09:09 PM
And I just slaved over this computer for a few days and finally came out with my almost finsihed product of 12KB and I must say I used it a lot... Well, you know what they say 12KB is better than 13KB (although I'm sure I didn't use it THAT much, anyway)!

Cloudski
07-12-2002, 10:07 PM
I guess it could be useful in certain circumstances, but then again, good ol' <? echo(" "); ?> could be needed at times :D

Mouldy_Goat
07-13-2002, 06:05 PM
Who voted no there?!

The <?=$text?> syntax is great, and is one of the only things ASP has going for it...

chrisvmarle
07-13-2002, 06:50 PM
Originally posted by Mouldy_Goat
Who voted no there?!

I did :(

Just because I didn't know it existed; "Do you ENJOY of this ability?" that's why

But then, who's the other one who voted no?

Mzzl, Chris

mouse
07-13-2002, 07:14 PM
Originally posted by Mouldy_Goat
Who voted no there?!

The <?=$text?> syntax is great, and is one of the only things ASP has going for it... I voted no as I see little benefit over current syntax, I'm no php-guru so maybe I'm wrong but it may cause problems when you don't want to print the variable such as loading it into a *.swf amongst other things.

mordred
07-15-2002, 10:18 AM
Why is this poll closed already - after two days and 7 votes?

Anyway, I vote for "No", because I hardly see any great benefits from this shortcut option. Does it work also when short_open_tags is disabled (for working in XML documents)? I'm a bit skeptic there.
I tend to favor things more in the long run that are still readable after a project is finished two months ago. And with this shorthand syntax, it could be another server-side language.

<?php echo $foo; ?> gets my support, though I try to avoid cluttering the HTML source with lots of simple variable echos.

firepages
07-15-2002, 11:13 AM
One of the first things that grabbed me about PHP was not that there seemed to be a way to do everything I wanted but that there were often several ways of doing it, I think this is the case here, most non PHP'ers could guess what <?=$str;?> meant in a second or so.

But I think the whole point here is for non-coders, i.e. designers who want to include pre-written features, I have just written a few forms for a client and all the client has to do is insert

<?=$client_application_form;?>

or whatever - wherever he wants it to appear in his page.

of course
<? echo ("$client_application_form");?>
<? echo $client_application_form;?>
<?print ("$client_application_form");?>
+ printr() & surreal combos of include & readfile & implode(,file())etc etc all work, but for a non-programmer the first causes less confusion, ok its hard to get <? echo $this;?> wrong but they do !

also its less typing so I use it wherever I can :thumbsup: