Link to home
Start Free TrialLog in
Avatar of maccaj51
maccaj51Flag for Afghanistan

asked on

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 == "127.0.0.1") { $status == "offline";}
else { $status == "online"; }

echo $status;


I know the $ipaddress is 127.0.0.1 but nothing echos

Thanks in advance
Avatar of Pratima
Pratima
Flag of India image

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

echo $status;
Avatar of Gnarf
Gnarf

Are you quite sure the ip address returned in fact is 127.0.0.1? 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

HTH
Gnarf
ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of maccaj51

ASKER

pratima_mcs GREAT SPOT!!!

Many Thanks