Sharp Tutorial
Function in php

Python

Java

C

C++

HTML/CSS

Java Script

PHP

SQL

C Programs

PHP Introduction

  • PHP home
  • PHP introduction
  • How to install and run
  • Syntax and Rule in PHP
  • Data type and operator
  • If else in php
  • Loop in php
  • Array in php
  • Sring in php
  • Function in php
  • Include in php

Working with Forms

  • Get and Post
  • Get Form input into PHP
  • Form Validation

PHP with MySQl

  • Connect PHP & Mysql
  • Insert using PHP Mysql
  • Select using PHP MySql
  • Delete Update using PHP Mysql
  • Login Page Example in PHP

Advanced PHP

  • Session in PHP
  • Cookies in PHP
  • File Handling in PHP
  • File Upload/Download PH

Object Oriented PHP

  • Class Obejct in PHP
  • Constructor in PHP
  • Destructor in PHP
  • Inheritance in PHP

Function in PHP

PHP has inbuilt functions even we can create user defined functions in php as well. inbuilt functions we can call directly. user defined function is created with the keyword function.

Syntax User defined function in php

<?php
function <functionName>()

{
// code here
}

functionName(); //to call the function
?>
 
 <?php
function myMsg()
{
echo "Welcome message in function";
}
myMsg();
?> 

output of the above program is Welcome message in function. We can also pass the argument to a function and function may also return the value as shown in following example.

<?php
function sum($a , $b)

{
$c=$a+$b;
return $c;
}
$sum=sum(10,20);
echo "the sum of 10 20 is".$sum;
?>

in the above program instead of static number value may be passed with the help of variable.Output of the above program is shown as below.

Enquiry about Course

Ask your Question

Click Here

Sharp (2) Tutorials

Video/ C Introduction

Watch video in full size

Video tutorial

Follow by Email
Facebook
Facebook
fb-share-icon
YouTube
Copyright © Sharp Tutorial
Build with WordPress
Wordpress Social Share Plugin powered by Ultimatelysocial
Sharp Tutorial