ohdang888 Posted August 6, 2008 Share Posted August 6, 2008 function test($var){ echo "you entered:". $var; } if you leave $var out. it says there is a missing requirement... how do i make $var optional? Link to comment https://forums.phpfreaks.com/topic/118351-solved-function-dont-require-var/ Share on other sites More sharing options...
BioBob Posted August 6, 2008 Share Posted August 6, 2008 function test($arg="default value") The $arg="default value" is only used when the function is called like test(); Otherwise it will use whatever argument is passed to it. $arg = 1; test($arg); value of arg is now 1, not its default value. Link to comment https://forums.phpfreaks.com/topic/118351-solved-function-dont-require-var/#findComment-609079 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.