Re: [PHP] Default setting garbage
Obviously PHP got confused with your data types. I'll bet that $basedate had been set to "5". Try this instead: GetNextDate("4", "2003-03", 5); Now I bet $frequency is 5 and $basedate is "" - Original Message - From: "Liam Gibbs" <[EMAIL PROTECTED]> Newsgroups: php.general To: "php list" <[EMAIL PROTECTED]> Sent: Tuesday, March 25, 2003 4:43 PM Subject: Re: [PHP] Default setting garbage > < check it or try to look at it? Sorry if that sounds insulting.. just trying > to search for the simplest explaination. : < >> > > No, no. Not insulting at all. That's often my problem. But not in this case. > I even went to the 'trouble' of copying and pasting $frequency wherever I > needed. > > > Original problem: > > Why is it that when I send call this function: > > function GetNextDate($whichfriday, $month = "", $frequency = 1, $basedate > = > > "") > > > > with this line: > > GetNextDate("4", "2003-03", "5"); > > > > that $frequency ends up ""? Whether I set it myself when I call the > > function, or I leave it blank and let the function set it itself, it ends > up > > with nothing in it. empty() returns 1, while isset() returns nothing on > > this. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Default setting garbage
On Thursday 27 March 2003 02:04, Liam Gibbs wrote: > > I'll guess that you're trying to access $frequency outside of the > > function, after you've called it, right? If so, read up on variable > > scope in the manual. > > No, I'm trying to access it inside the function. This is what I have (or an > example, since I don't have it right in front of me right now): > > function func($a = 1, $b = 2) { > print("[$a]"); > } > > From the above example, I get [] as output. This works as expected: function func($a = 1, $b = 2) { print("[$a]"); } func(); // prints: [1] -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Insufficient facts always invite danger. -- Spock, "Space Seed", stardate 3141.9 */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Default setting garbage
> > I'll guess that you're trying to access $frequency outside of the > > function, after you've called it, right? If so, read up on variable > > scope in the manual. > > No, I'm trying to access it inside the function. This is what I have (or an > example, since I don't have it right in front of me right now): > > function func($a = 1, $b = 2) { > print("[$a]"); > } > > >From the above example, I get [] as output. Well, my guess was wrong. I guess it has to happen eventually. :) So how are you calling the function? If you have: function func($a=1,$b=2) { print("[$a]"); } func(); all by itself, does it work? No reason it shouldn't. Maybe you think you're passing a value to func(), but you're really not. In order to get what you say, you _have_ to be passing an empty string as the first parameter. Wait... you realize that if you call func(''); That $a in the function will be an empty string, right? $b would get the default value of 2. They would only get that default value if you do not include that parameter in the function call at all. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Default setting garbage
> I'll guess that you're trying to access $frequency outside of the > function, after you've called it, right? If so, read up on variable > scope in the manual. No, I'm trying to access it inside the function. This is what I have (or an example, since I don't have it right in front of me right now): function func($a = 1, $b = 2) { print("[$a]"); } >From the above example, I get [] as output. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Default setting garbage
> Why is it that when I send call this function: > function GetNextDate($whichfriday, $month = "", $frequency = 1, $basedate > = "") > > with this line: > GetNextDate("4", "2003-03", "5"); > > that $frequency ends up ""? Whether I set it myself when I call the > function, or I leave it blank and let the function set it itself, it ends > up with nothing in it. empty() returns 1, while isset() returns nothing on > this. I'll guess that you're trying to access $frequency outside of the function, after you've called it, right? If so, read up on variable scope in the manual. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Default setting garbage
- Original Message - From: "Liam Gibbs" <[EMAIL PROTECTED]> To: "php list" <[EMAIL PROTECTED]> Sent: Tuesday, March 25, 2003 2:10 PM Subject: [PHP] Default setting garbage Why is it that when I send call this function: function GetNextDate($whichfriday, $month = "", $frequency = 1, $basedate = "") with this line: GetNextDate("4", "2003-03", "5"); that $frequency ends up ""? Whether I set it myself when I call the function, or I leave it blank and let the function set it itself, it ends up with nothing in it. empty() returns 1, while isset() returns nothing on this. Good question. Are you certain your not misspelling "frequency" when you check it or try to look at it? Sorry if that sounds insulting.. just trying to search for the simplest explaination. : < - Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Default setting garbage
<> No, no. Not insulting at all. That's often my problem. But not in this case. I even went to the 'trouble' of copying and pasting $frequency wherever I needed. Original problem: > Why is it that when I send call this function: > function GetNextDate($whichfriday, $month = "", $frequency = 1, $basedate = > "") > > with this line: > GetNextDate("4", "2003-03", "5"); > > that $frequency ends up ""? Whether I set it myself when I call the > function, or I leave it blank and let the function set it itself, it ends up > with nothing in it. empty() returns 1, while isset() returns nothing on > this. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php