Re: note 13527 added to function.strpos.php

From: Date: Thu, 21 Jun 2001 01:35:44 +0000
Subject: Re: note 13527 added to function.strpos.php
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-14507@lists.php.net to get a copy of this message
This note should probably go in http://php.net/manual/en/language.operators.comparison.php instead of strpos() :) Also, perhaps this is not the best code for new coders to see - it is likely to get them into bad habits, writing code that they cannot easily debug. --zak ----- Original Message ----- From: <aulbach@unter.franken.de> To: <php-notes@lists.php.net> Sent: Wednesday, June 20, 2001 8:47 AM Subject: [PHP-NOTES] note 13527 added to function.strpos.php > Note the following: > > The === or !== operators do have a higher precedence than == or != operators. This can harm you in the case, that if you write sth like > > if ( $pos=strpos($hugo,'/') !== false ) > ... > > This dosn't work, PHP evals this like in the following order: > > if ( $pos= ( strpos($hugo,'/') !== false ) ) > ... > > which means, that $pos is at the end either true or false (which is not what you in most cases wanted - I think :-). So the correct writing for this is > > if ( ( $pos=strpos($hugo,'/') ) !== false ) > ... > > http://php.fidion.de/manual/en/function.strpos.php > > > -- > PHP Notes Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-notes-unsubscribe@lists.php.net > For additional commands, e-mail: php-notes-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.notes (#14507) next »