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 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    49
    Thanks
    1
    Thanked 1 Time in 1 Post

    PHP version incompatibility

    Working on a project at work and home. At work we use PHP 4.3 and home I use WAMP with PHP 5.2. The following snippet from a class I found in public domain. This code works fine on PHP 4.3 but outputs part of the program code in PHP 5.2.
    PHP Code:
    /**
    * Returns markup for displaying the calendar.
    *
    * @return
    * @public
    */
    function display ( )
    {
        ob_start();
    ?>
        <table border="0" cellspacing="0" cellpadding="0" width="<?=$this->tblWidth?>">
            <?=$this->dspDayNames()?>
            <?=$this->dspDayCells()?>
        </table>
    <?php
        $c 
    ob_get_contents();
        
    ob_end_clean();
        return 
    $c;
    }
    The output in the browser is:

    dspDayNames()?> dspDayCells()?>

    Now I know the issue with short start tags and yes the PHP 4.3 has it turned on and the PHP 5.2 does not - but even if I convert the <? to <?php it still doesn't work. Why? And what is the purpose of <?= anyways? I can't find any reference to this so far in the docs.

    Thanks
    Of all the things I've lost in my life time, my mind is the one I miss the most!

  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    PHP Code:
    <?=
    ...is an echo() shortcut that will only work if short tags are enabled.

    Instead of:
    PHP Code:
    <?=$this->dspDayNames()?>
    ...try:
    PHP Code:
    <?php echo $this->dspDayNames(); ?>

  • #3
    New Coder
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    49
    Thanks
    1
    Thanked 1 Time in 1 Post
    Beautiful ! Just replaced all the occurances throughout the class and bingo.

    Thanks.
    Of all the things I've lost in my life time, my mind is the one I miss the most!


  •  

    Posting Permissions

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