-1

simple question >>

i'm now learning php and i get some things in mind wich is >>>

how it's can be done ! ... wich my question is :

is the echo have or i can do unset or something that if (if statement got true ) remove the echo or unset echo or something ?

like this ... :

$name = belal ;

echo "$name";

if ($name == belal ) {

  "unset echo (or) "remove echo "


 }

Note : " (or) i not mean by it that i execute as a code it's word so i can explaining my question "

this is not a question that i need it really for build something

it's just a "query" in my mind specially

i'm go to learning php 100% so i want everything in my mind ask to it Decidedly

so thanks

user2864740
  • 60,010
  • 15
  • 145
  • 220
Belal
  • 1
  • 1
  • of course i know how to set a variable again ... but a just asking remove echo .... thanks – Belal May 01 '14 at 03:54
  • See the duplicate question/answer, but *don't use this approach* even if it can be used. Simply, only echo/write output when you *should*. – user2864740 May 01 '14 at 03:56
  • yes this link is reset a variable witch is easy and known but just i'm asking if echo can removed with if statment ... thanks – Belal May 01 '14 at 03:58
  • so like im said it's a just small qustion that i get out of learning with out missed word in php hhh .. thanks man – Belal May 01 '14 at 03:59

2 Answers2

0

Do the check before the echo or if this is for a website echo the content in a <span> tag and use CSS to hide it.

Checking before the echo:

$name = "foo";
if( $name == "foo" ){
    echo $name;
}

Changing the CSS:

$name = "foo";
echo '<span class="hidey">'.$name.'</span>';
$name = "bar";
if( $name != "foo"){
    echo "<style>.hidey{ display: none;</style>";
}
0

For output control I can only think of Output Control Functions in the PHP documentation.

Try to look into the example of ob_get_contents.

Hope this helps.

MISJHA
  • 998
  • 4
  • 12