visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: PHP :: Supressing Warnings


By: PHP newbee U.S.A.  Date: 06/03/2003 00:00:00  English  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 English  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 English  Type : Comment
Thanks VGR. :)
By: VGR Date: 06/03/2003 18:35:00 English  Type : Comment
no problem.
By: PHP newbee Date: 09/03/2003 00:37:00 English  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 English  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

EContact
browser fav
page generated in 216.559170 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page