...

View Full Version : PHP version incompatibility



Nightchild
08-15-2007, 04:26 AM
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.

/**
* 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

kbluhm
08-15-2007, 04:53 AM
<?=
...is an echo() shortcut that will only work if short tags are enabled.

Instead of:

<?=$this->dspDayNames()?>
...try:

<?php echo $this->dspDayNames(); ?>

Nightchild
08-15-2007, 05:12 AM
Beautiful ! Just replaced all the occurances throughout the class and bingo.

Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum