RE: [PHP] beginner needs help!
| From: | Kim Madsen | Date: | Fri, 13 May 2005 06:18:10 +0000 |
| Subject: | RE: [PHP] beginner needs help! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-215116@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Jay Blanchard [mailto:jay.blanchard@niicommunications.com]
> Sent: Thursday, May 12, 2005 9:37 PM
> > var $exportFile = "Export." . date("mdy") . ".txt";
>
> > I seem to be able to use the date function is I am not starting the
> > declaration with "var", but then my program is not working correctly.
> [/snip]
>
> You may have to assemble it beforehand sort of ...
>
> $exportFileName = "Export." . date("mdy") . ".txt";
> var $exportFile = $exportFileName;
May? You _have_ to. This behavior was introduced in PHP4 as the only non-PHP3 compatible OOP
behavoir as far as I know. Nice spotted for a beginner Rochelle :-) I mean the "I´m not
allowed to use a function call while declaring with var".
Explanation:
PHP3 allowed one to use a function call while declaring a variable:
var $welcome_text = "Welcome " . get_username_from_db($loginname) . ". Today is
" . date("l") . ", have a nice day";
As of PHP4 one _can´t_ use a function call when declaring a var, but _has_ to do as in Your example
Jay:
var $welcome_text;
$welcome_text = "Welcome " . get_username_from_db($loginname) . ". Today is " .
date("l") . ", have a nice day";
Pay attention to this though: You _not_ suppose to use var to declare a variable unless it´s inside
a class. I never really tested that before, but outside a class this won´t work:
<?
var $test = "hello";
echo $test; // returns nothing
?>
--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper