version_compare
am 30.09.2010 17:43:22 von 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
Re: version_compare
am 30.09.2010 18:01:48 von hSiplu
On Thu, Sep 30, 2010 at 9:43 PM, Brian Smither 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
Re: version_compare
am 30.09.2010 18:03:03 von 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
Re: version_compare
am 30.09.2010 18:37:24 von 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
Re: version_compare
am 30.09.2010 18:52:55 von 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
Re: version_compare
am 30.09.2010 20:58:37 von 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
filter_var (was: Re: [PHP] version_compare)
am 30.09.2010 22:30:10 von 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