PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$handle = fopen("http://www.google.com", "r");
if ($handle)
{
}
in the above statement,what does if($handle) mean? can u expand it for me?does it mean
if ($handle==true)?
if fopen is not successful,$handle returns null value.
thanks
swetha
Last edited by swetha on Fri Oct 17, 2008 4:53 am, edited 1 time in total.
$str="http://www.google.com";
$handle = fopen($str, "r");
if ($handle)
{
}
in the above line fopen($str, "r"),how do i check if an invalid website is entered.
fopen should not be executed if an invalid site is opened.
eg for invalid $str variables.
$str="http://wwww.google.com";
$str="http:";
$str="http://www.sgdjkag.com";
etc.
Actually, the $handle variable in your code is a file pointer reference if the file was successfully opened, not a boolean TRUE.
The check is the kind of lazy PHP programming to validate such things, since most values are cast to a boolean TRUE except 0 and FALSE.
A more correct way to check it would be: