Search
 
SCRIPT & CODE EXAMPLE
 

PHP

define function parameters php

<?php
  #Syntax:
  function functionName() {
    code to be executed;
  }

  function Greetings() {
    echo "Hello, welcome!";
  }
  
  Greetings(); #Execute function 

  #Function arguements

  #Function arguements are just like prefixes/suffixes and can have multiple arguements

  function Polygon(str $prefix = penta, str $suffix = gon) {
    echo "$prefix$suffix"
  }

  Polygon("tetra", "gon");
  Polygon(); #Here, we use default value
  Polygon("hexa", "gon");
  Polygon("septa", "gon");
?>
Comment

php functions parameters

// functions require 'function' keyword
// separate the parameters with a comma
function addFunction($num1, $num2) {
	$sum = $num1 + $num2;
	echo "Sum of the two numbers is : $sum";
}

addFunction(1, 2); // echoes: Sum of the two numbers is : 3
Comment

php pass a function as a parameter

function someFunc($a)
{
    echo $a;
}

function callFunc($name)
{
    $name('funky!');
}

callFunc('someFunc');
Comment

PREVIOUS NEXT
Code Example
Php :: send attachment in mail php 
Php :: php datetime set timezone 
Php :: duplicate record laravel 
Php :: string to boolean php 
Php :: Laravel Syntax error or access violation: 1071 Specified key was too long 
Php :: magento getcollection get first 
Php :: php catch all exceptions 
Php :: create seeder in laravel 
Php :: Add Empty Cart Button WooCommerce 
Php :: hello world php 
Php :: laravel get single column value 
Php :: how to make classess in php 
Php :: generate laravel event 
Php :: automatically make created_by and updated_by laravel 
Php :: laravel observer check if field changed 
Php :: json_encode() in php 
Php :: php implode array 
Php :: web api return json example in php 
Php :: change the php version in linux 
Php :: php get src content from image tag 
Php :: php if negative make positive 
Php :: Get current taxonomy term ID of the active page 
Php :: factory laravel 
Php :: sort array php 
Php :: big int php 
Php :: laravel create project with auth 2021 
Php :: laravel find many 
Php :: if browser url is having domain name in it check using php 
Php :: set cookie one day php 
Php :: calculate total time from start and end datetime in php 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =