How do i check if a string contains a specific number?

Dear Experts

This script wont work for some reason...

$ipaddress = gethostbyname($domain);

if ($ipaddress == "") { $status == "offline";}
else { $status == "online"; }

echo $status;

I know the $ipaddress is but nothing echos

Thanks in advance
Who is Participating?
Pratima PharandeConnect With a Mentor Commented:
if ($ipaddress == "") { $status = "offline";}
else { $status = "online"; }

echo $status;

you are using "==" for assignmetn change it as above
 $status = "offline";
Pratima PharandeCommented:
if ($ipaddress == "") { $status = "offline";}
else { $status = "online"; }

echo $status;
Are you quite sure the ip address returned in fact is Either, gethostbyname will return null (misspelling of the host name) or the IP adress retuirned is the one assigned to your computer. In case of a company network this may one starting with  192.168.

To find out:
Check if $ipaddress is null
If it is not, use the echo command or something similar to print it out
Enclose the output into special characters, lets say the pipe sign. This will help you detect leading or trailing white spaces

maccaj51Author Commented:
pratima_mcs GREAT SPOT!!!

Many Thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.