![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| Hi... I seem to remember reading somewhere about the proper way of doing this sort of thing in the middle of some html, for example: <a href="<?= $some_url_or_other ?>">Click this!</a> What is the most proper way of doing such? Would it be to do the full monty?: <a href="<?php echo $some_url_or_other ?>">Click this!</a> I am writing my output to be xhtml strict compliant, so I guess for continuity alone it should be the latter, but are there any specific reasons for using the long-winded way? I'd like to know people's thoughts... HYCSSLOTS... Plankmeister. | |||
| Advertisements |
| | #2 | ||
| In article <3f41d39e$0$32454$edfadb0f@dread16.news.tele.dk> , The Plankmeister <plankmeister_NO_@_SPAM_hotmail.com> wrote: > <a href="<?php echo $some_url_or_other ?>">Click this!</a> Use this one. | |||
| | #3 | ||
| On Tue, 19 Aug 2003 02:16:13 -0600 in <message-id:190820030216135042%unix_core@linuxmail.org> E-Star <unix_core@linuxmail.org> wrote: > In article <3f41d39e$0$32454$edfadb0f@dread16.news.tele.dk> , The > Plankmeister <plankmeister_NO_@_SPAM_hotmail.com> wrote: > > > <a href="<?php echo $some_url_or_other ?>">Click this!</a> > > Use this one. .... and to explain why to the OP... <? ?> can be used if shorttags is enabled in php.ini but this isn't always the case for every server and I suspect becoming less and less the case as more and more people use XML for various tasks. XML uses <?xml as it's tag, and causes confusion with PHP, so it's always advisable (IMO at least) to use the <?php rather than <? (extending to the echo <?php echo rather than <?= too). HTH =) Regards, Ian -- Ian.H [Design & Development] digiServ Network - Web solutions www.digiserv.net | irc.digiserv.net | forum.digiserv.net Programming, Web design, development & hosting. | |||
| | #4 | ||
| Ian.H [dS] wrote: > <? ?> can be used if shorttags is enabled in php.ini but this isn't > always the case for every server and I suspect becoming less and less > the case as more and more people use XML for various tasks. XML uses > <?xml as it's tag, and causes confusion with PHP, so it's always > advisable (IMO at least) to use the <?php rather than <? (extending to > the echo <?php echo rather than <?= too). shorttags off has the advantage that you can use "<?xml" directly in your files (i.e. without having to "print()" or "echo()" it), but if you do that, you lose the ability to run your script on a server that has shorttags on. If you're going to run only on servers who's php.ini you control, that's no problem, but the default is still shorttags=on, so that is what most hosters use. So, if you're coding for the general public, shorttags=on is more common, but you can't rely on it, so it is safer to use "<?php echo...". But you can't rely on shorttags=off either, so for xhtml compliant files you should use <?php echo "<?xml....";?> Jochen -- /** * @author Jochen Buennagel <zang at buennagel dot com> * @see http://www.sourceforge.net/projects/zang */ | |||
| | #5 | ||
| XHTML doesn't really care which version you use... The absolute best way anyway seems to be <?PHP echo $url;?> Notice the ;... Doesn't matter though, just that it seems better as chances are you might feel like extending that piece of code and forget to att the ; at that point... -- // DvDmanDT MSN: dvdmandt@hotmail.com Mail: dvdmandt@telia.com "The Plankmeister" <plankmeister_NO_@_SPAM_hotmail.com> skrev i meddelandet news:3f41d39e$0$32454$edfadb0f@dread16.news.tele.d k... > Hi... > > I seem to remember reading somewhere about the proper way of doing this sort > of thing in the middle of some html, for example: > > <a href="<?= $some_url_or_other ?>">Click this!</a> > > What is the most proper way of doing such? Would it be to do the full > monty?: > > <a href="<?php echo $some_url_or_other ?>">Click this!</a> > > I am writing my output to be xhtml strict compliant, so I guess for > continuity alone it should be the latter, but are there any specific reasons > for using the long-winded way? I'd like to know people's thoughts... > > HYCSSLOTS... > > > Plankmeister. > > | |||
| | #6 | ||
| "The Plankmeister" <plankmeister_NO_@_SPAM_hotmail.com> wrote in message news:<3f41d39e$0$32454$edfadb0f@dread16.news.tele. dk>... > Hi... > > I seem to remember reading somewhere about the proper way of doing this sort > of thing in the middle of some html, for example: > > <a href="<?= $some_url_or_other ?>">Click this!</a> > > What is the most proper way of doing such? Would it be to do the full > monty?: > > <a href="<?php echo $some_url_or_other ?>">Click this!</a> I prefer short tag <?=$foo?> 'cos it's IMO quite fast. Also, I hate echo and would prefer to write PHP code without the use of echo. (Many thanks to Rasmus for fighting on behalf of short tags | |||
| | #7 | ||
| Jochen Buennagel wrote: > Ian.H [dS] wrote: > >> <? ?> can be used if shorttags is enabled in php.ini but this isn't >> always the case for every server and I suspect becoming less and less >> the case as more and more people use XML for various tasks. XML uses >> <?xml as it's tag, and causes confusion with PHP, so it's always >> advisable (IMO at least) to use the <?php rather than <? (extending to >> the echo <?php echo rather than <?= too). > > > shorttags off has the advantage that you can use "<?xml" directly in > your files (i.e. without having to "print()" or "echo()" it), but if you > do that, you lose the ability to run your script on a server that has > shorttags on. If you're going to run only on servers who's php.ini you > control, that's no problem, but the default is still shorttags=on, so > that is what most hosters use. > > So, if you're coding for the general public, shorttags=on is more > common, but you can't rely on it, so it is safer to use "<?php echo...". > But you can't rely on shorttags=off either, so for xhtml compliant files > you should use <?php echo "<?xml....";?> > > Jochen > Or use: if(ini_get('short_open_tag') == 'on') { [code to be executed if shorttag is enabled] } else { [code to be excecuted with shorttag disabled] } Robert | |||
| Featured Websites | ||||
|
![]() |
| Tags: echo, ltphp, some_var_or_other |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Echo getting Parse error | Jeffrey Ellis | PHP | 8 | 07-01-2007 5:09 PM |
| echo using bluetooth headset with anycom usb-100 | Dietmar Krick | Bluetooth Software and Hardware | 3 | 06-17-2007 12:24 PM |
| echo... | Phil Da Lick! | Computer Consoles | 2 | 05-30-2007 10:05 PM |
| Featured Websites | ||||
|