php-general | 2005051
Date: 05/13/05
- Next message: Richard Lynch: "Re: [PHP] Help!!! Cannot do Authentication"
- Previous message: Richard Lynch: "Re: [PHP] 'Require' and 'Select' lists"
- Maybe in reply to: Clinton, Rochelle A: "[PHP] beginner needs help!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> -----Original Message-----
> From: Jay Blanchard [mailto:jay.blanchard <email protected>]
> 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-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: Richard Lynch: "Re: [PHP] Help!!! Cannot do Authentication"
- Previous message: Richard Lynch: "Re: [PHP] 'Require' and 'Select' lists"
- Maybe in reply to: Clinton, Rochelle A: "[PHP] beginner needs help!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

