PHP Programming Problem, Reading From Text File!?
My .php file contains:
<?php
$f=fopen("welcome.txt","r") or exit("Unable to open file!");
while (!feof($f))
{
$x=fgetc($f);
If $x="<"
{
echo"oooooooooooooooooo";
}
echo $x;
}
fclose($f);
?>
and My welcome.txt file contains:
hello world
<title> its title </title>
When I run the php file in wamp, nothing happens, but If I remove the below part, it works!
If $x="<"
{
echo"oooooooooooooooooo";
}
But I dont want to remove this part, How can I fix it? Do you have the same problem?
Thank you
<?php
$f=fopen("welcome.txt","r") or exit("Unable to open file!");
while (!feof($f))
{
$x=fgetc($f);
If $x="<"
{
echo"oooooooooooooooooo";
}
echo $x;
}
fclose($f);
?>
and My welcome.txt file contains:
hello world
<title> its title </title>
When I run the php file in wamp, nothing happens, but If I remove the below part, it works!
If $x="<"
{
echo"oooooooooooooooooo";
}
But I dont want to remove this part, How can I fix it? Do you have the same problem?
Thank you
Your comparison statement is wrong.
The correct statement is:
If ($x=="<")
The correct statement is:
If ($x=="<")
Your comparison statement is wrong.
The correct statement is:
If ($x=="<")
The correct statement is:
If ($x=="<")
you have a wrong syntax in if condition and should be written like this:
if ($x < some value) {
echo "OOOOOOOOO";
}
if ($x < some value) {
echo "OOOOOOOOO";
}