Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

whats wrong w/ this script?

Posted on 2007-03-28
7
Medium Priority
?
235 Views
Last Modified: 2008-02-01

<?

if((isset($_SERVER["HTTP_USER_AGENT"])&&is_numeric(stripos($_SERVER["HTTP_USER_AGENT"], "hey")))||
$_SERVER["QUERY_STRING"]=="hey"||(isset($_SERVER["REMOTE_HOST"])&&strpos($_SERVER["REMOTE_HOST"],"hey")))
{

} else {
echo 'yo';
}



 ?>

Fatal error: Call to undefined function: stripos() in /homdex.php on line 5
0
Comment
Question by:JPERKS1985
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 2000 total points
ID: 18811984
That isn't a function.  Do you mean strpos() or strrpos()?

Let me know if you need details or the difference on those.

bol
0
 
LVL 20

Expert Comment

by:steelseth12
ID: 18811993
Its only available in php > 5
more info at http://www.php.net/manual/en/function.stripos.php
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 18812005
Never mind.  I misread the function name.  What version of PHP are you using?

bol
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 18812025
If you don't know the version you can use phpinfo() to find out.  Make a page with just the lines below in it and save it as phpinfo.php.  Then run it in your browser.

<?php
phpinfo();
?>

It looks like Steelseth12 is thinking the same thing. :)

bol
0
 
LVL 20

Expert Comment

by:steelseth12
ID: 18812031
you could use stripos(strtolower($_SERVER["HTTP_USER_AGENT"]), "hey")
0
 
LVL 5

Expert Comment

by:NickVd
ID: 18812230
What I do if I know I'll require a function that may not exist is to create it myself in php and wrap it in a conditional if the function does not exist.

This way you can use the newer functions on older versions of php!

Taken from the pear package 'php_compat'
--------
if (!function_exists('stripos')) {
    function stripos($haystack, $needle, $offset = null)
    {
        if (!is_scalar($haystack)) {
            user_error('stripos() expects parameter 1 to be string, ' .
                gettype($haystack) . ' given', E_USER_WARNING);
            return false;
        }
   
        if (!is_scalar($needle)) {
            user_error('stripos() needle is not a string or an integer.', E_USER_WARNING);
            return false;
        }
   
        if (!is_int($offset) && !is_bool($offset) && !is_null($offset)) {
            user_error('stripos() expects parameter 3 to be long, ' .
                gettype($offset) . ' given', E_USER_WARNING);
            return false;
        }
   
        // Manipulate the string if there is an offset
        $fix = 0;
        if (!is_null($offset)) {
            if ($offset > 0) {
                $haystack = substr($haystack, $offset, strlen($haystack) - $offset);
                $fix = $offset;
            }
        }
   
        $segments = explode(strtolower($needle), strtolower($haystack), 2);
   
        // Check there was a match
        if (count($segments) === 1) {
            return false;
        }
   
        $position = strlen($segments[0]) + $fix;
        return $position;
    }
}
--------
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 18939974
I'm glad I could help.  Thank you for the grade, the points and the fun question.

bol
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question