Function - What does the parameter somethingnull mean in PHP

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

We got a PHP file in school with some functions and one of them is the following:

function serviceRec($db,$table,$afields=null,$avalues=null){ .... }

My question: What does the $afields=null and $avalues=null mean?

Thank you!

Answers

function serviceRec($db,$table,$afields=null,$avalues=null){ .... }

It means that, when you call your function and don t pass those parameters then it ll by default place value as null

  Example :   
function hello($name = "anonymous"){
    return "Hello $name 
";
}

echo hello();//Hello anonymous
echo hello("BigSeeProduction");//Hello BigSeeProduction

http://php.net/manual/en/functions.arguments.php#functions.arguments.default http://php.net/manual/en/functions.arguments.php#functions.arguments.default

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/30545174/what-does-the-parameter-something-null-mean-in-php

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils