How to use if statement (it is false in all time)?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hdbbdh
    New Member
    • Dec 2008
    • 24

    #1

    How to use if statement (it is false in all time)?

    Hello everyone,

    I am trying to read text file to get my data from it, but unfortunatly, there is something wrong, and i am unable to find it, so would you please help me in that?

    The php code is:
    Code:
    <?php
    $DataFile = "myfile.php";
    $FileStream = fopen($DataFile, 'r');
    $Line = fgets($FileStream);
    if($Line == "This is the first line")
    {
    	$Line = fgets($FileStream);
    	echo $Line;
    }
    else
    {
    	echo "Wrong file";
    }
    fclose($FileStream);
    ?>
    And myfile.php contain:
    Code:
    This is the first line
    This is the second line
    Finally, the result is:
    Code:
    Wrong file
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    This type of issue always confused me. But The thing is when you are reading first line you are not getting
    "This is the first line"
    You are getting two possible value depending your Editor
    1."This is the first line\r"
    2."This is the first line\r\n"

    Make your judgement

    Comment

    • hdbbdh
      New Member
      • Dec 2008
      • 24

      #3
      Thank you very very very much Johny.

      Comment

      Working...