简体   繁体   中英

How to remove the echo in this PHP code?

I have the following PHP Code

#The facebook message
$fh = fopen('comments.txt', 'r') or die('Unable to open data1.txt');
while($line = fgetcsv($fh, 0, '||' )) {
   if ($line[0] == $name) {
       echo <<<EOL
My color is $line[2]
EOL;
       break; // if there's only ever one '5678' line in the, get out now.
   }
}
fclose($fh);
$fb = $line[2];

I would like to remove the echo ie remove the "My color is...." on the user's browser please. How can I remove the code without getting any errors please?

I tried many times... I am still a beginner to PHP.

Thanks.

// echo <<<EOL
// My color is $line[2]
// EOL;

You can comment out code like that.

If you don't have any treatments in the if statement, you can comment the whole block :

#The facebook message
$fh = fopen('comments.txt', 'r') or die('Unable to open data1.txt');
while($line = fgetcsv($fh, 0, '||' )) {
   if ($line[0] == $name) {
       /*
       echo <<<EOL
       My color is $line[2]
       EOL;
       */
       break; // if there's only ever one '5678' line in the, get out now.
   }
}
fclose($fh);
$fb = $line[2]; 

You can comment out or delete the following code:

/*echo <<<EOL
My color is $line[2]
EOL;*/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM