Jump to content

Echo Variables


arunpatal

Recommended Posts

Hello everyone,

 

I have a file call config.php which look like this (i can change value to yes and no)

 

<?php
$header_toping = 'yes';
?>

 

now there is file call header.php which look like this

 

<style type="text/css">#Layer1{background-color: #FFAD5B;}</style>



<?php
require 'config.php';
$topping = '<div id="Layer1" style="position:absolute;text-align:center;left:0px;top:0px;width:100%;height:33px;z-index:0;" title=""> </div>
</br>
</br>';
?>



<table id="header_table">
<td id="header"> TEXT </td>
</table>
<table id="header_menu">
<!--You can edit menu here-->
<td> <a href="index.php">HOME</a>   ·   <a href="products.php">PRODUCTS</a>   ·   <a href="#">Contact</a> </td>
</table>

 

How can i echo $topping variable in header.php page by selecting

the value yes in confing.php ???

and if i select no then it should not echo the $topping

Link to comment
https://forums.phpfreaks.com/topic/271108-echo-variables/
Share on other sites

<?php
require("config.php");
$topping    =   "<div id='Layer1' style='position:absolute;text-align:center;
			    left:0px;top:0px;width:100%;height:33px;z-index:0;' title=''> </div>";
$topping    .=  "</br></br>";
if($header_toping = "yes"){
   echo $topping;
}else{
   echo "";
}
?>
   then here put your html

Link to comment
https://forums.phpfreaks.com/topic/271108-echo-variables/#findComment-1394758
Share on other sites

<?php
require("config.php");
$topping = "<div id='Layer1' style='position:absolute;text-align:center;
			 left:0px;top:0px;width:100%;height:33px;z-index:0;' title=''> </div>";
$topping .= "</br></br>";
if($header_toping = "yes"){
echo $topping;
}else{
echo "";
}
?>
then here put your html

 

I tried it but it just echo $topping

when i set no in config.php

like this

<?php
$header_toping = 'no';
?>

 

It still print $topping

Link to comment
https://forums.phpfreaks.com/topic/271108-echo-variables/#findComment-1394768
Share on other sites

An equal comparison is two == or three === (depending on if you want to match values or values and types.) One = is an assignment operator.

An equal comparison is two == or three === (depending on if you want to match values or values and types.) One = is an assignment operator.

 

Thanks it was such a stupid biggner mistake.

 

hope it helped @

arunpatal

Link to comment
https://forums.phpfreaks.com/topic/271108-echo-variables/#findComment-1394771
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.