Re: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-31 Thread Alexander Skwar

So sprach »Arcadius  A.« am 2001-08-31 um 17:36:51 -0700 :
> Would this work ?

Kinda, but not really.

If you want to do this, you've got to stuff it all in one function, like
so:

function dunno($mandatory, $optional1 = NULL, $opt2 = NULL){
if (NULL === $optional1){
// behave, as if only $mandatory is set
echo 'mandatory is: ' . $mandatory;
return;
}
if (NULL === $optional2){
// behave, as if $man. and $opt1 have set
echo 'mand is : ' . $mandatory;
echo 'opt1 is : ' . $optional1;
return;
}
// neither $opt1 nor $opt2 are null
echo 'mand is : ' . $mandatory;
echo 'opt1 is : ' . $optional1;
echo 'opt2 is : ' . $opt2;
return;
}

Alexander Skwar
-- 
How to quote:   http://learn.to/quote (german) http://quote.6x.to (english)
Homepage:   http://www.digitalprojects.com   |   http://www.iso-top.de
   iso-top.de - Die günstige Art an Linux Distributionen zu kommen
Uptime: 2 days 2 hours 31 minutes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-31 Thread Arcadius A.

Ok .I see Thanks to you both !
Have a nice weekend 
Arcad


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-31 Thread Philip Olson


> One of the downside of PHP IMHO is, that you do not have to define
> variables.  This leads to a lot of errors.  At least there should be a
> "option", which forces you to define variables, like maybe so:

I've not followed this thread but this is pretty much what E_NOTICE is
for, turn it on in error_reporting and it'll tell you every undefined
variable.  Do this in php.ini or with error_reporting function.  In fact,
one _should_ develop with E_ALL on.

 if ($var) // will produce a Warning if $var is not set

 echo $notset; // ditto

 $arr[somekey] // Warning if constant variable somekey is 
  not defined (i.e. use 'quotes')

 $arr['key']   // Warning if key 'key' not defined

See :

  http://www.php.net/manual/en/phpdevel-errors.php
  http://marc.theaimsgroup.com/?l=php-general&m=99486381324867

Much more can be said, hope the above helps.

Regards,
Philip Olson



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-31 Thread Boget, Chris

> Cool ...
> Now that we're talking about PHP 
> I'd like to ask a question 
> You know the "overloading" function in C++  Is that 
> possible in PHP ?

No, I do not believe so.
 
> Basically , I'd like to define  more than one function having 
> the same name but different number of variables/parameters ... 
> so PHP would know which one I'm calling depending on the 
> numbwer/type of the variables ... exemple :

You can do this with variable parameters.  Something along
these lines:

function myFunc( $requiredVar, $optionalVar1 = "", $optionalVar2 = "" ) {
  echo "$requiredVar\n";

  if( $optionalVar1 ) {
echo "$optionalVar1\n";

  } 
// etc.
}

Alternately, if you need *alot* of optional vars, consider passing
an array and check that.

Chris



Re: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-31 Thread Arcadius A.

Cool ...
Now that we're talking about PHP 
I'd like to ask a question 
You know the "overloading" function in C++  Is that possible in PHP ?

Basically , I'd like to define  more than one function having the same name
but different number of variables/parameters ... so PHP would know which one
I'm calling depending on the numbwer/type of the variables ...
exemple :





Would this work ?

Thanks...

- Original Message -
From: "Alexander Skwar" <[EMAIL PROTECTED]>
To: "Boget, Chris" <[EMAIL PROTECTED]>
Cc: "Arcadius A." <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, August 31, 2001 8:21 AM
Subject: Re: [PHP] PHP_SELF or REQUEST_URI within Function ?


> So sprach »Boget, Chris« am 2001-08-31 um 10:22:28 -0500 :
> > True.  But take the following function:
> >
> > function processLotsOfFormVars() {
> >   global $fieldOne, $fieldTwo, $fieldThree, $fieldFour;
> >   global $fieldFive, $fieldSix, $fieldSeven;
> >   global $PHP_SELF, $REQUEST_URI;
> >   global $HTTP_REFERER;
> >
> >   echo "Field One is: $fieldOne\n";
> >   echo "Field Two is: $fieldTwo\n";
> > // etc
> > }
> >
> > OR you can do it this way:
> >
> > function processLotsOfFormVars() {
> >   echo "Field One is: $GLOBALS[fieldOne]\n";
> >   echo "Field Two is: $GLOBALS[fieldTwo]\n";
> > // etc
> > }
>
> Uh?  I don't see it.  The "matching" function 1 is:
>
> function processLotsOfFormVars() {
> global $fieldOne;
> global $fieldTwo;
>
> echo "Field One is: $fieldOne\n";
> echo "Field Two is: $fieldTwo\n";
> }
>
> this quite doesn't look as intimidating as the piece you wrote.  And
> even if there are 10 lines of 'global', I still like it a lot better,
> because it CLEARLY shows which form vars are going to be used.
>
> One of the downside of PHP IMHO is, that you do not have to define
> variables.  This leads to a lot of errors.  At least there should be a
> "option", which forces you to define variables, like maybe so:
>
> dim $some_var;
>
> this leads to easier readable code IMHO.
>
> > variables in a function.  Plus, if the function gets large,
> > it's easier to see where the value is coming from by using
> > the $GLOBALS variable.
>
> Now, that's the point I'm arguing here.  I don't think so.
>
> Alexander Skwar
> --
> How to quote: http://learn.to/quote (german) http://quote.6x.to (english)
> Homepage: http://www.digitalprojects.com   |   http://www.iso-top.de
>iso-top.de - Die günstige Art an Linux Distributionen zu kommen
> Uptime: 2 days 2 hours 10 minutes
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-31 Thread Boget, Chris

> One of the downside of PHP IMHO is, that you do not have to define
> variables.  This leads to a lot of errors.  At least there should be a
> "option", which forces you to define variables, like maybe so:
>   dim $some_var;

I definitely agree there.  I've been bitten by this bug more times
than I can count.  Granted, it's always been my fault, but it would
have been nice to have something there to say "hey, this variable
hasn't been defined".  I know you can make PHP do this if you set
the error checking very, very high but in doing so, you are also
opening up another bucket of worms that you don't always need
to deal with.

> > variables in a function.  Plus, if the function gets large, 
> > it's easier to see where the value is coming from by using
> > the $GLOBALS variable.
> Now, that's the point I'm arguing here.  I don't think so.

This is definitely a matter of coding style.  Neither of us are
wrong, just a matter of preference.  In replying, I was simply
offering alternatives so that Arcadius would know all options
open to him.  I wasn't trying to say your way was erroneous
and if I came off that way, my apologies.

Chris



Re: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-31 Thread Alexander Skwar

So sprach »Boget, Chris« am 2001-08-31 um 10:22:28 -0500 :
> True.  But take the following function:
> 
> function processLotsOfFormVars() {
>   global $fieldOne, $fieldTwo, $fieldThree, $fieldFour;
>   global $fieldFive, $fieldSix, $fieldSeven;
>   global $PHP_SELF, $REQUEST_URI;
>   global $HTTP_REFERER;
> 
>   echo "Field One is: $fieldOne\n";
>   echo "Field Two is: $fieldTwo\n";
> // etc
> }
> 
> OR you can do it this way:
> 
> function processLotsOfFormVars() {
>   echo "Field One is: $GLOBALS[fieldOne]\n";
>   echo "Field Two is: $GLOBALS[fieldTwo]\n";
> // etc
> }

Uh?  I don't see it.  The "matching" function 1 is:

function processLotsOfFormVars() {
global $fieldOne;
global $fieldTwo;

echo "Field One is: $fieldOne\n";
echo "Field Two is: $fieldTwo\n";
}

this quite doesn't look as intimidating as the piece you wrote.  And
even if there are 10 lines of 'global', I still like it a lot better,
because it CLEARLY shows which form vars are going to be used.

One of the downside of PHP IMHO is, that you do not have to define
variables.  This leads to a lot of errors.  At least there should be a
"option", which forces you to define variables, like maybe so:

dim $some_var;

this leads to easier readable code IMHO.

> variables in a function.  Plus, if the function gets large, 
> it's easier to see where the value is coming from by using
> the $GLOBALS variable.

Now, that's the point I'm arguing here.  I don't think so.

Alexander Skwar
-- 
How to quote:   http://learn.to/quote (german) http://quote.6x.to (english)
Homepage:   http://www.digitalprojects.com   |   http://www.iso-top.de
   iso-top.de - Die günstige Art an Linux Distributionen zu kommen
Uptime: 2 days 2 hours 10 minutes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-31 Thread Arcadius A.

RE: [PHP] PHP_SELF or REQUEST_URI within Function ?Ok Men !!!. Now I see  
thanks alot for the inputs ! :o))

Arcad


  - Original Message - 
  From: Boget, Chris 
  To: 'Alexander Skwar' 
  Cc: Arcadius A. ; [EMAIL PROTECTED] 
  Sent: Friday, August 31, 2001 8:22 AM
  Subject: RE: [PHP] PHP_SELF or REQUEST_URI within Function ?


  > > Or, so you don't have to specify all the variables you are using 
  > > as globals (especially if you are using *alot* of them), you can 
  > > use: 
  > > $GLOBALS[SCRIPT_FILENAME]; 
  > What's the gain?  'global ' has 7 characters, whereas '$GLOBALS[]' has 
  > 10 characters.  So, you don't type less.  And with using global(), the 
  > code is more orderly, and thus easier to read. 

  True.  But take the following function: 

  function processLotsOfFormVars() { 
global $fieldOne, $fieldTwo, $fieldThree, $fieldFour; 
global $fieldFive, $fieldSix, $fieldSeven; 
global $PHP_SELF, $REQUEST_URI; 
global $HTTP_REFERER; 

echo "Field One is: $fieldOne\n"; 
echo "Field Two is: $fieldTwo\n"; 
  // etc 
  } 

  OR you can do it this way: 

  function processLotsOfFormVars() { 
echo "Field One is: $GLOBALS[fieldOne]\n"; 
echo "Field Two is: $GLOBALS[fieldTwo]\n"; 
  // etc 
  } 

  I've done it both ways.  I'm not advocating using 
  "$GLOBALS[var_name];" over "global $var_name", 
  just that it is an alternative if you are using alot of global 
  variables in a function.  Plus, if the function gets large, 
  it's easier to see where the value is coming from by using 
  the $GLOBALS variable. 
  That's all I was saying. 

  Chris 




RE: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-31 Thread Boget, Chris

> > Or, so you don't have to specify all the variables you are using 
> > as globals (especially if you are using *alot* of them), you can 
> > use:
> > $GLOBALS[SCRIPT_FILENAME];
> What's the gain?  'global ' has 7 characters, whereas '$GLOBALS[]' has
> 10 characters.  So, you don't type less.  And with using global(), the
> code is more orderly, and thus easier to read.

True.  But take the following function:

function processLotsOfFormVars() {
  global $fieldOne, $fieldTwo, $fieldThree, $fieldFour;
  global $fieldFive, $fieldSix, $fieldSeven;
  global $PHP_SELF, $REQUEST_URI;
  global $HTTP_REFERER;

  echo "Field One is: $fieldOne\n";
  echo "Field Two is: $fieldTwo\n";
// etc
}

OR you can do it this way:

function processLotsOfFormVars() {
  echo "Field One is: $GLOBALS[fieldOne]\n";
  echo "Field Two is: $GLOBALS[fieldTwo]\n";
// etc
}

I've done it both ways.  I'm not advocating using 
"$GLOBALS[var_name];" over "global $var_name",
just that it is an alternative if you are using alot of global 
variables in a function.  Plus, if the function gets large, 
it's easier to see where the value is coming from by using
the $GLOBALS variable.
That's all I was saying.

Chris



Re: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-31 Thread Alexander Skwar

So sprach »Boget, Chris« am 2001-08-31 um 10:04:49 -0500 :
> Or, so you don't have to specify all the variables you are using 
> as globals (especially if you are using *alot* of them), you can 
> use:
> 
> $GLOBALS[SCRIPT_FILENAME];

What's the gain?  'global ' has 7 characters, whereas '$GLOBALS[]' has
10 characters.  So, you don't type less.  And with using global(), the
code is more orderly, and thus easier to read.

Alexander Skwar
-- 
How to quote:   http://learn.to/quote (german) http://quote.6x.to (english)
Homepage:   http://www.digitalprojects.com   |   http://www.iso-top.de
   iso-top.de - Die günstige Art an Linux Distributionen zu kommen
Uptime: 2 days 2 hours 0 minutes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-31 Thread Boget, Chris

> So sprach »Arcadius  A.« am 2001-08-31 um 05:27:04 -0700 :
> > $u = $SCRIPT_FILENAME;
> Because you did not define $SCRIPT_FILENAME anywhere.  If you want to
> access the global variable, you've got to say so:
> global $SCRIPT_FILENAME;

Or, so you don't have to specify all the variables you are using 
as globals (especially if you are using *alot* of them), you can 
use:

$GLOBALS[SCRIPT_FILENAME];

Chris



Re: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-31 Thread Alexander Skwar

So sprach »Arcadius  A.« am 2001-08-31 um 05:27:04 -0700 :
> $u = $SCRIPT_FILENAME;

Because you did not define $SCRIPT_FILENAME anywhere.  If you want to
access the global variable, you've got to say so:

global $SCRIPT_FILENAME;

Alexander Skwar
-- 
How to quote:   http://learn.to/quote (german) http://quote.6x.to (english)
Homepage:   http://www.digitalprojects.com   |   http://www.iso-top.de
   iso-top.de - Die günstige Art an Linux Distributionen zu kommen
Uptime: 2 days 1 hour 46 minutes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-31 Thread Arcadius A.

Thanks  Jack 

arcad.

"Jack Dempsey" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> you have to use $GLOBALS["SCRIPT_FILENAME"]
>
> jack
>
> "Arcadius A." wrote:
>
> > Hello !
> > Why this script   prints an empty string(it prints nothing) as the
value of
> > the variable "u" ?
> > This happens even if  $REQUEST_URI or PHP_SELF is used instead of
> > SCRIPT_FILENAME .
> > Thanks...
> >
> >  > function menu( $theurl)
> > {
> > //global $u ;
> > $u = $SCRIPT_FILENAME;
> > echo $u;
> > echo $theurl;
> > }
> > ?>
> >
> > Hello there !!!
> >
> > 
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-30 Thread Jason Murray

>  function menu( $theurl)
> {
> //global $u ;
> $u = $SCRIPT_FILENAME;
> echo $u;
> echo $theurl;
> }
> ?>
> 
> Hello there !!!
> 
> 

Variable scope.

You need a "global $SCRIPT_FILENAME;" at the top of the function.

Jason

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-30 Thread Jack Dempsey

you have to use $GLOBALS["SCRIPT_FILENAME"]

jack

"Arcadius A." wrote:

> Hello !
> Why this script   prints an empty string(it prints nothing) as the  value of
> the variable "u" ?
> This happens even if  $REQUEST_URI or PHP_SELF is used instead of
> SCRIPT_FILENAME .
> Thanks...
>
>  function menu( $theurl)
> {
> //global $u ;
> $u = $SCRIPT_FILENAME;
> echo $u;
> echo $theurl;
> }
> ?>
>
> Hello there !!!
>
> 
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]