Re: [PHP] What am I missing here?

2010-06-28 Thread Jay Ess

Rick Dwyer wrote:

Hello List.

I am completely at a loss for why the line of code below returns the 
desired value:


$PATH_INFO= substr($_SERVER['REQUEST_URI'],strlen($_SERVER['SCRI
PT_NAME']), strlen($_SERVER['REQUEST_URI']));

BUT, putting the same line of code on 1 line fails to return anything:

$PATH_INFO= 
substr($_SERVER['REQUEST_URI'],strlen($_SERVER['SCRIPT_NAME']), 
strlen($_SERVER['REQUEST_URI']));

strlen counts the newline so probably should you put a +1.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] What am I missing here?

2010-06-21 Thread Simcha Younger
On Sat, 19 Jun 2010 13:21:02 -0400
Rick Dwyer rpdw...@earthlink.net wrote:

 Hello List.
 
 I am completely at a loss for why the line of code below returns the  
 desired value:
 
 $PATH_INFO= substr($_SERVER['REQUEST_URI'],strlen($_SERVER['SCRI
 PT_NAME']), strlen($_SERVER['REQUEST_URI']));
 
 BUT, putting the same line of code on 1 line fails to return anything:
 
 $PATH_INFO=  
 substr($_SERVER['REQUEST_URI'],strlen($_SERVER['SCRIPT_NAME']),  
 strlen($_SERVER['REQUEST_URI']));
 
 
 
   --Rick
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

It looks like since you broke your key in the first line, the value returned is 
0, since the key 'SRI PT_NAME' does not exist.
When you fixed this, SCRIPT_NAME was the same length as REQUEST_URI so nothing 
was returned.

look at the documentation on substr, you need to fix you parameters.
-- 
Simcha Younger sim...@syounger.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] what am I missing here?

2002-08-15 Thread Rasmus Lerdorf

You are missing operator precedence.  ! is higher precedence than == so
your statement effectively becomes:

  if ( (!$key) == $info_keys[0])

which makes no sense.

Normally you would write that code as:

  if ( $key != $info_keys[0] )

-Rasmus

On Thu, 15 Aug 2002, Alexander Ross wrote:

 what am i missing here??  I have a simple if statement that wont do whats
 inside it even when true.

 this works:

echo $key==$info_keys[0]; // returns 1 or 0 correctly
 if($key==$info_keys[0])
   $query = $query;
 else  $query = $query. and ;
 $query = $query.$key.='.$val.';

 this doesn't:
  // the $query = $query. and ; just doesn't get executed .. nor does any
 other statment I put inside the if statement

echo $key==$info_keys[0]; // returns 1 or 0 correctly
 if(!$key==$info_keys[0])// if it isn't the first item in the array
  $query = $query. and ;
 $query = $query.$key.='.$val.';



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php