DeathRay2K Posted March 11, 2008 Share Posted March 11, 2008 In the "Session name" topic, I noticed JustSomeGuy recommended using <?php over <?, and I was just wondering if there is any good reason to do so? Link to comment Share on other sites More sharing options...
Wander Posted March 11, 2008 Share Posted March 11, 2008 <? only works when thats enabled in the php.ini files, many ppl have this switched off, and if they use any scripts of you that contains <? it wont work, therefore its better to make everything with <?php to be sure noone gets trouble with it Link to comment Share on other sites More sharing options...
justsomeguy Posted March 11, 2008 Share Posted March 11, 2008 The XML preamble starts with <?. Many servers have short tags disabled so that PHP doesn't try to run XML or XHTML files that have a .php extension. In other words, a "valid" XHTML file starts off like this: <?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> That is from the W3C XHTML template. If you have PHP code in that file and save it as .php then PHP will try to execute the XML preamble at the top and you'll get an error, so some servers have short tags disabled. If you're trying to make your code portable then it's always best to use the long tags. Link to comment Share on other sites More sharing options...
music_lp90 Posted March 12, 2008 Share Posted March 12, 2008 is the <?= tag a dangerous one to use as well? or is that not a short tag? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 12, 2008 Share Posted March 12, 2008 It's not really a tag itself, it's just a shortcut for <? echo. It won't work if short tags are disabled. None of these tags are "dangerous", but there's an issue of portability if you choose to use short tags. Your applications will not run on some servers. Link to comment Share on other sites More sharing options...
Synook Posted March 13, 2008 Share Posted March 13, 2008 Well it could be "dangerous" in the sense that if the PHP code isn't parsed by the server and outputted in the source that is sent to the client's browser, then they could go "view source" and may get potentially sensitive information such as database connection information. Link to comment Share on other sites More sharing options...
justsomeguy Posted March 13, 2008 Share Posted March 13, 2008 Well I would hope that when you upload the code you would notice that it's not running before any clients got to it. If you're putting broken applications online and not noticing they are broken then short tags aren't your only problem. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.