You are here: Re: strpos for <? and ?> problem « PHP Programming Language « IT news, forums, messages
Re: strpos for <? and ?> problem

Posted by Julien CROUZET on 11/17/70 11:39

julian_m avait énoncé :
> Julien CROUZET wrote:
>
>> The probleme is here if : (strpos($buffer, '<?') === true){
>>
>> strpos returns the position of the first occurence of your searched
>> string or FALSE if it doesn't find it.
>>
>> The operator === is a STRICT comparison, that means that it'll be true
>> if the operands are EXACTLY the same.
>>
>> As your strpos finds a '<?', it returns its position in your file,
>> (ie: 45), and 45 is not EXACTLY true.
>>
>> You have to change
>> strpos($buffer, '<?') === true){
>> for
>> strpos($buffer, '<?') !== false){
>>
>
> two things:
> 1st: You're faster than the light! Your advice works nice. Thanks!
>
> 2nd: What would be EXACTLY true? 1?
>

Only true is EXACTLY true.

For example, is_array($_POST) will be EXACTLY true, as it returns true.

The reason for such a strict comparison is that strpos returns the
index of the found substring, so if your string starts with '<?',
strpos will return 0 (position 0).

In a large comparison, (0 == false), but in a STRICT one, (0 !==
FALSE).

if (strpos($buffer, '<?') !== FALSE)
means if we find '<php'
if (strpos($buffer, '<?') != FALSE)
means if we find '<?php', after the first character of buffer




--
Julien CROUZET - DSI Theoconcept
julien.crouzet@/enlever ca\theoconcept.com
http://www.theoconcept.com

 

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

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