SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Oct 2003
    Location
    Sweden
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Beginner question

    Hi,

    I have started to follow the tutorial "Build your own Database Driven Website using PHP & MySQL - Part 3: Getting Started with PHP".

    The problem i have is that the statement "<?=$_SERVER['PHP_SELF']?>" in the samplecode does not work.

    If i replace it with "<?php echo($_SERVER['PHP_SELF'] ?>" it works.

    What could be wrong?

    Regards,

    Mats

  2. #2
    does not play well with others frezno's Avatar
    Join Date
    Jan 2003
    Location
    Munich, Germany
    Posts
    1,391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Genfors
    Hi,

    I have started to follow the tutorial "Build your own Database Driven Website using PHP & MySQL - Part 3: Getting Started with PHP".

    The problem i have is that the statement "<?=$_SERVER['PHP_SELF']?>" in the samplecode does not work.
    could be that short tags in php.ini is disabled.

    As a good habit you shouldnt use short tags anyway.
    If i replace it with "<?php echo($_SERVER['PHP_SELF'] ?>" it works.
    That cannot work (typo?), since there's a paranthesis opened but no more closed.

    with
    PHP Code:
    <?php echo $_SERVER['PHP_SELF']; ?>
    you are on the save side (if your PHP version already knows the Superglobals) .
    Last edited by frezno; Oct 10, 2003 at 06:28.
    We are the Borg. Resistance is futile. Prepare to be assimilated.
    I'm Pentium of Borg.Division is futile.Prepare to be approximated.

  3. #3
    One website at a time mmj's Avatar
    Join Date
    Feb 2001
    Location
    Melbourne Australia
    Posts
    6,282
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    http://www.php.net/manual/en/language.basic-syntax.php

    The <? and ?> symbols can be used in an HTML or XML document to indicate some sort of code that should be interpreted by the application.

    You can choose to escape from HTML in a PHP file in four different ways.

    Using <?php and ?> (always available)
    Using <script language="php"> and </script> (always available)
    Using <? and ?> (available by default, but can be disabled)
    Using <% and %> (available by default, but can be disabled)

    Chances are, parsing PHP within <? and ?> tags is disabled in the php.ini file on your server.

    These are called "short tags" by PHP. Short tags are discouraged, because not all php.ini files support them and because they may conflict with a future technology which also uses <?
    [mmj] My magic jigsaw
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The Bit Depth Blog Twitter Contact me
    Neon Javascript Framework Jokes Android stuff

  4. #4
    SitePoint Member
    Join Date
    Oct 2003
    Location
    Sweden
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by frezno
    could be that short tags in php.ini is disabled.

    As a good habit you shouldnt use short tags anyway.That cannot work (typo?), since there's a paranthesis opened but no more closed.

    with
    PHP Code:
    <?php echo $_SERVER['PHP_SELF']; ?>
    you are on the save side (if your PHP version already knows the Superglobals) .
    Ok, thanks.

    And yes it was a typo, it should be "<?php echo($_SERVER['PHP_SELF']); ?>"



    --Mats

  5. #5
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ecause they may conflict with a future technology which also uses <?
    XML for example. Writing XHTML 1.1 with short_tags = on can be quite a pain.


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
  •