SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    = before variable

    Hi,

    I have come across this lately:

    <?=$_SERVER['PHP_SELF']?>

    Its even in a sitepoint tutorial where there is an = in front of a variable instead of using echo.

    Can anyone explain what is does and when it can be used. I know it doesn't work in if statements and can't work out why, yet it works in the above form.

    Thanks,

    Matt

  2. #2
    SitePoint Addict mmanders's Avatar
    Join Date
    Jul 2006
    Location
    Edinburgh, Scotland
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is essentially a short hand for outputting a single variable in the middle of HTML mode. As far as I know, it's use is deprecated to some extent because the use of the shorthand delimiters
    PHP Code:
    <??>
    instead of full
    PHP Code:
    <?php ?>
    is considered bad practice; also a lot of what I have read has suggested that one should really use the full syntax:
    PHP Code:
    <?php echo $_SERVER['PHP_SELF']; ?>

  3. #3
    SitePoint Zealot geekofdaweek's Avatar
    Join Date
    May 2006
    Location
    Erie, PA, USA
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't be lazy....use the full syntax. By doing so, you will have a much easier time if and when you upgrade your server, or if your server is upgraded by someone else (hosted for you).
    John Stuttler
    Owner, Camboro Computers
    There are 10 kinds of people...
    Those who understand computers, and those who don't!


Bookmarks

Posting Permissions

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