answersLogoWhite

0


Best Answer

With strstr you can find a certain letter, number, or symbol in a string. A basic function could be to figure out if an email address is valid or not.

$email = "email@email.com";

$domain = strstr($email,"@");

$dot = strstr($domain,".");

if ($domain "")

{

do something

}

else

{

do something else

}

?>

The strstr in $domain is looking for "@" in $email and the strstr in $dot is looking for a "." in $domain. The if means if $domain and $dot equal nothing(it would show up as blank because there is no "@" in $email so the strstr in $domain returns false and that would in turn return the strstr in $dot as false also), do something. then the else is if $domain and $dot equal something besides "" do something else.

The stristr function is just a Case-Insensitive version of strstr.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the functionality of the function strstr and stristr in PHP?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is difference between language constracter and function for exampal echo print in php language?

I think you mean language construct... Anyway, a function usually takes one or more arguments as comma separated values or variables. echo and print don't <?php $email = 'user@example.com'; $domain = strstr($email, '@'); echo $domain; // prints @example.com ?> Here the strstr function takes a variable string and a constant string as an argument. echo simply displays the contents of the resulting variable. There are a couple functions that don't require arguments, like die() & exit()


What year was PHP invented?

Rasmus Lerdorf released PHP publicly on June 8, 1995 to accelerate bug location and improve the code. This release was named PHP version 2 and already had the basic functionality that PHP has today.


How does PHP function in applications?

in php used for one typ website


How do you use settime out in php?

we cant use set timeout function in php because it is of java script function


How do you return a value in a PHP function?

Below is a simple example of how you could return a value in a PHP function. <?php function returnme($value) { return $value; } echo returnme('hello'); // outputs: hello ?>


What is the way to create a function in PHP?

function function_name() { .................... }


What does the php function eval?

The eval() function evaluates a string as PHP code. http://us.php.net/manual/en/function.eval.php


What is this mean because i already have the latest version of php ..Fatal error Call to undefined function array column()?

array_column is of course a function, additional functionality was even added in 7.0.0. The only problems I could imagine would be if you are missing the underscore (it is array_column()), or that some part of your installation was corrupt. If the underscore didn't fix it, you could try reinstalling PHP.


How do you use a function with a button in PHP?

A simple function call <html> <body> <?php if(isset($_POST['button'])) { setValue(); // Function is called } function setValue() { echo "<br>The button property to call PHP function works"; // Your code here } ?> <input type="submit" name="button" onclick=<?php $_SERVER['PHP_SELF']; ?> /> </body> </head>


How do you change the current directory in PHP?

chdir() PHP function helps in changing the current directory.


What is the getopt function in PHP?

It gets options from the command line argument list. It can be used in PHP 4.3 and above, including PHP 5.


How do you find out the number of arguments passed to a function in PHP?

With a call to the function func_num_args().