Kelly Hallman wrote: > On Fri, 21 Nov 2003, Wouter van Vliet wrote: >> Point is, which of the inline printing style is preferred by you >> guyes. I tend to use <?=$Var?> a lot, since it reads easier but get >> into struggles with myself when I do that multiple times in a row. > > Ultimately I think you'd want to be doing very little of any, > if you're working with more than a basic, one-page script. > > Even if you are (gulp) generating your HTML output within > functions, it seems better to be returning that back to some > level where there are only a couple of echo/prints necessary.. > > Think output layer... >
Yep, that's how I usually think. For projects set up by me I usually put as many as none logic into the output scripts, and just have them echo some values. For example, on a news-page I call a function which returns an array with (non-layout) specific values. And it are those values that make it their way to <?=$News['Title']?> and stuff like that. Sometimes though, I find myself in a situation wheren I am merely changing someone else's code and their approach isn't always (=usually not) like this at all. But this is not really what the topic is about ;) Chris Shiflett wrote: > --- "Chris W. Parker" <[EMAIL PROTECTED]> wrote: >> I also prefer <?= $variable ?> to <?php echo $variable; ?> except >> that for the sake of cross-system compatibility* I now choose to do >> <?php echo $variable; ?>. > > I think explicitly using echo is much more readable. While it > may be obvious to many what <?= does, it is one more little > thing that might seem like magic to someone else. The less of > that type of syntax, the better, in my opinion. If you want > magic syntax, there's Perl. It has a lot of great shortcuts, > if you're familiar with the syntax. With PHP, most things you > don't understand are easy to look up. I'd rather search for "echo" > than "<?=" if I was new to PHP. I disagree on that. <?php echo $Var; ?> is much longer and causes lines to wrap and stuff. That is what I find unreadable. Yes, <?=$Var?> looks a bit like magic, but no more than Harry Potter magic. Not like Gdanalf magic or anything. If you want Gandalf magic, I can give you some: <?=($WhoseMagic=='Tolkien'?'Gandalf':'Harry Potter')?> Still I care more about compactness than the level of "magic". Good programmers/scripters could read my code, bad ones can't. This is called natural selection, since bad scripters should stay out of my code. :P:P > >> * What I mean by that is if I give my code to someone else I want it >> to work with as few changes as possible. Some php installs don't have >> <? ?> turned on (short tags?). > > Right, plus I don't think <?php= will work (you might have > been suggesting this). This was discussed on the internals > list a year or two ago, and it was voted down. Too bad, is anything known about maybe implementing a new directive next to short_open_tags .. Something like short_echo_style, so that you won't be allowed to open tags the short way, while still being able to echo in short style. I see them as two different entities. > > Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php