Articles → PHP → Functions In PHP

Functions In PHP






Software Requirement




  1. XAMPP is installed on your machine
  2. Any text editor like Notepad

Technical Knowledge





What Are The Functions Of PHP?





Syntax


function function_name(parameters separated by comma) {
 // Code
}



Example




<?php
function Message()
{
    echo ("Hello");
}

Message();
?>





Function With Arguments




<?php
function Message($name)
{
    echo ("Hello " . $name);
}

Message("Gyan");
?>





Default Argument In PHP




<?php
function Message($name = "Gyan")
{
    echo ("Hello " . $name);
}

Message();
?>





Return Values In PHP




<?php
function Sum($num1, $num2)
{
    return $num1 + $num2;
}

echo (Sum(1, 2));
?>





Posted By  -  Karan Gupta
 
Posted On  -  Saturday, November 1, 2014

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250