create a variable php code example

Example 1: set php var to html

<?php ob_start();?>
<div>Contents goes <b>here</b></div>
<?php $contents=ob_get_clean();?>

Example 2: php variables

<?php
  $string = 'string';
  $number = 1;
?>

Example 3: php variables

<?php
/* In PHP, a variable starts with the $ sign, 
followed by the name of the variable:
*/

$txt = "Hello world!";
$x = 5;
$y = 10.5;
?>

Example 4: php is variable a function

is_callable($var) // returns true if variable is a function

Tags:

Php Example