WolfRage Posted July 18, 2009 Share Posted July 18, 2009 This may be an easy one, but I don't know the answer. I want to create some custom functions and I want to have them sometimes accept variables but other times if no variables are provided to fall back on defaults. I understand how to check whether or not the variables were provided, but it is the matter of not generating a PHP warning when the variables are not provided. Link to comment https://forums.phpfreaks.com/topic/166425-solved-can-i-create-a-custom-function-to-accept-variables-or-not-with-out-warnings/ Share on other sites More sharing options...
MadTechie Posted July 18, 2009 Share Posted July 18, 2009 you mean like this ? function test($v = "default") { //do stuff return $v; } echo test(); echo test("testing"); Link to comment https://forums.phpfreaks.com/topic/166425-solved-can-i-create-a-custom-function-to-accept-variables-or-not-with-out-warnings/#findComment-877622 Share on other sites More sharing options...
WolfRage Posted July 18, 2009 Author Share Posted July 18, 2009 So it was easy, guess I never picked up on that before. Thanks! Now I can do what I have been trying to work around. Link to comment https://forums.phpfreaks.com/topic/166425-solved-can-i-create-a-custom-function-to-accept-variables-or-not-with-out-warnings/#findComment-877624 Share on other sites More sharing options...
MadTechie Posted July 18, 2009 Share Posted July 18, 2009 if($solved == true) { echo "Can you click solved bottom left please"; } Link to comment https://forums.phpfreaks.com/topic/166425-solved-can-i-create-a-custom-function-to-accept-variables-or-not-with-out-warnings/#findComment-877626 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.