Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: <? or <?PHP

  1. #1
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts

    <? or <?PHP

    Am I correct in my thoughts that I had read somewhere that <? will only work in later versions, or maybe if Global is turned on?

    Someone told me that they work the same and it doesn't make any difference which one you use, but I am finding that the <? won't work on my version.

    Any comments on where I may have read about this?

    Ken

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Well depending on the PHP settings as well, <? might not work. I forget what the option is called but I know I had to enable it on the last apache web server I setup a couple weeks ago.
    OracleGuy

  • #3
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Short tags is what you're looking for.
    http://ca.php.net/manual/en/ini.core...short-open-tag

  • #4
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    <? works with any version of PHP worth considering, but it's possible to turn off support in the php settings, the 'short tags' option or something similar, therefore if you want code that you know will work regardless of local settings, avoid the use of <? and <?= and stick to <?php.
    If that's not going to be an issue for you, then use whichever you prefer, I personally use <?= (to echo a variable) in the middle of html, as I think it's neater, but some would disagree.
    (if you're not familiar with <?=, then the two lines below are the same:
    PHP Code:
    <a href="http://www.example.com/<?php echo $pagename;?>">Click!</a>
    //and
    <a href="http://www.example.com/<?=$pagename?>">Click!</a>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •