Languages :: PHP :: Supressing Warnings |
|||
| By: PHP newbee |
Date: 06/03/2003 00:00:00 |
Points: 50 | Status: Answered Quality : Excellent |
|
Hi All! If I define a function like so: // Start of Code function printviewform($var) { // End of Code Is there any way I can supress the warnings given if the argument $var isn't passed to it? Any help is appreciated, |
|||
| By: VGR | Date: 06/03/2003 09:48:00 | Type : Answer |
|
| yes, of course. Make it (Ada-Like) an optional parameter by providing a default value declare the function as : function printviewform($var="") { and that's all |
|||
| By: PHP newbee | Date: 06/03/2003 16:11:00 | Type : Comment |
|
| Thanks VGR. :) |
|||
| By: VGR | Date: 06/03/2003 18:35:00 | Type : Comment |
|
| no problem. | |||
| By: PHP newbee | Date: 09/03/2003 00:37:00 | Type : Comment |
|
| PS. With your example above, would that not restrict any value being passed to $var, as it sets it to "" when the function is called? Or am I being clueless again? |
|||
| By: VGR | Date: 09/03/2003 18:55:00 | Type : Comment |
|
| no it's the default value, that's the one if no value is provided as an argument if $var received a value by argument, fine. If no argument makes it through, $var will have it's default value as per the si gnature of the function. This is 100% ADA |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








