You are here: Re: newbie - variable to string « PHP Programming Language « IT news, forums, messages
Re: newbie - variable to string

Posted by Janwillem Borleffs on 12/18/96 11:52

Jarrod wrote:
> $testing = '10';
> $end = end($array); // this would equal to 10
>
>
> if($testing == $end){
> print 'yes';
> }else{
> print 'no';
> }
>

This should work as long as $end contains the integer 10, or a string "10".
When it contains "10" followed by a space or another alphanumeric character,
it will fail, because $testing being defined as a string, $end will also be
considered as and converted to a string for the condition evaluation and
'10' isn't equal to '10 '.

The simplest workaround would be to ensure that $testing contains an integer
($testing = 10;), which causes $end to be considered in the condition as a
number.


JW

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация