Return value from function in PHP

Description

The following code shows how to return value from function.

Example


/*  w ww  .j  a  v a2  s . co m*/
<?php
  function makeBold($text)
  {
    $text = "<b>$text</b>";
    return($text);
  }

  print("This Line is not Bold<br>\n");
  print(makeBold("This Line is Bold") . "<br>\n");
  print("This Line is not Bold<br>\n");
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Language Basic »




PHP Introduction
PHP Operators
PHP Statements
Variable
PHP Function Create
Exception
PHP Class Definition