Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

w2ksp4.exe, WwwxxXdbf, procmail "FROM_MAILER" patch, Use of assignment to $[ is deprecated at /usr/local/sbin/apxs line 86. , wwwxxx vim, mysql closing table and opening table, 800c5000, setgid operation not permitted, pciehp: acpi_pciehprm on IBM, WWWXXX.DBF

Links

XODOX
Impressum

#1: version_compare

Posted on 2010-09-30 17:43:22 by Brian Smither

I found this code...
if (version_compare(PHP_VERSION, '5.2.0', '>=3D')) {
$text=3Dfilter_var($text, FILTER_SANITIZE_URL);
}

....to be questionable.

Under what conditions would version_compare() return true, yet the=
filter_var() be undefined? Because that's what is happening.

Thank you.




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

Report this message

#2: Re: version_compare

Posted on 2010-09-30 18:01:48 by hSiplu

On Thu, Sep 30, 2010 at 9:43 PM, Brian Smither <bhsmither@gmail.com> wrote:
>
> I found this code...
> if (version_compare(PHP_VERSION, '5.2.0', '>=3D')) {
It means condition (PHP_VERSION >=3D 5.2.0)

>  $text=3Dfilter_var($text, FILTER_SANITIZE_URL);
> }
>
> ...to be questionable.
>
> Under what conditions would version_compare() return true, yet the filter=
_var() be undefined? Because that's what is happening.
>
> Thank you.
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



--=20
Shiplu Mokadd.im
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest)

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

Report this message

#3: Re: version_compare

Posted on 2010-09-30 18:03:03 by Paul M Foster

On Thu, Sep 30, 2010 at 09:43:22AM -0600, Brian Smither wrote:

>
> I found this code...
> if (version_compare(PHP_VERSION, '5.2.0', '>=')) {
> $text=filter_var($text, FILTER_SANITIZE_URL);
> }
>
> ...to be questionable.
>
> Under what conditions would version_compare() return true, yet the filter_var() be undefined? Because that's what is happening.

If your PHP was compiled without support for the filter functions? I
assume when you say that filter_var() is "undefined" you mean that the
software returns a message that the function itself cannot be found?

Paul

--
Paul M. Foster

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

Report this message

#4: Re: version_compare

Posted on 2010-09-30 18:37:24 by List Manager

Brian Smither wrote:
> I found this code...
> if (version_compare(PHP_VERSION, '5.2.0', '>=')) {
> $text=filter_var($text, FILTER_SANITIZE_URL);
> }
>
> ...to be questionable.
>
> Under what conditions would version_compare() return true, yet the filter_var() be undefined? Because that's what is happening.
>
> Thank you.
>
>
>
>

Personally, I would change that to be

if ( function_exists('filter_var') ) {
$text = filter_var($text, FILTER_SANITIZE_URL);
}

Jim

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

Report this message

#5: Re: version_compare

Posted on 2010-09-30 18:52:55 by Brian Smither

>Personally, I would change that to be
>if ( function_exists('filter_var') ) {

So would I:
*But it's not my code.
*I wish to learn and understand the cause of the problem - not walk around=
it.

>It means condition (PHP_VERSION >=3D 5.2.0)

I understand that. There was a second, more relevant, part to my question.

I have found the version of PHP used as reported in the HTTP header=
responses.

filter_var() is undefined in PHP/5.2.4_p20070914-pl2-gentoo




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

Report this message

#6: Re: version_compare

Posted on 2010-09-30 20:58:37 by List Manager

Brian Smither wrote:
>> Personally, I would change that to be
>> if ( function_exists('filter_var') ) {
>
> So would I:
> *But it's not my code.
> *I wish to learn and understand the cause of the problem - not walk around it.
>
>> It means condition (PHP_VERSION >= 5.2.0)
>
> I understand that. There was a second, more relevant, part to my question.
>
> I have found the version of PHP used as reported in the HTTP header responses.
>
> filter_var() is undefined in PHP/5.2.4_p20070914-pl2-gentoo
>

As Paul pointed out, maybe your version of PHP was built without the filter_var
function compiled in.

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

Report this message

#7: filter_var (was: Re: [PHP] version_compare)

Posted on 2010-09-30 22:30:10 by Brian Smither

>As Paul pointed out, maybe your version of PHP was built without the
>filter_var function compiled in.

This is what I have learned about PHP with filter_var() as an illustrative=
point:

Many people who provide elaborations on PHP make too many assumptions or=
are blatently and woefully incomplete. Statements such as "PHP 5.2.0 or=
higher is required for this to work" is misleading. The PHP online manual=
pages for respective functions make no distinction that any particular=
function or capability is an optional include for a build - considered an=
"extension" as opposed to, what?, "native code"?

I have also learned that when coding my own scripts, I must not only read=
the manual page for that function, but also any metadata for it and its=
group, such as the Introduction page, Installing/Configuring, etc. And=
where, when I finally find it, if I can reason out that I should be=
looking for it, it may say "The filter extension is enabled by default as=
of PHP 5.2.0", that I need to be reasonably cautious because some idiot=
may build PHP 5.2.0+ without this extension.

Are the array_*() functions also an optional extension?



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

Report this message