Jump to content

[SOLVED] function creation help


Lodius2000

Recommended Posts

blarg Im drawing a major blank

 

in defining this function I want $size to be an optional value, it doesn't need to be there, and if it isnt there then html makes a default sized text input, if it is there is makes a text input at the size that is placed there, but when i call the function using

 

input_text('name', $_POST);

 

i am getting a warning:Missing argument 3 for input_text()

 

<?php
function input_text($element_name, $values, $size){
print '<input type="text" name="' . $element_name .'" value="';
print htmlentities($values[$element_name]) . '"';
if(isset($size)){
	print 'size="'.$size.'"';
}
print ' />';
}
?>

 

I tried putting an else{ print "";} but that didnt work

 

so how do I make argument 3 optional

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/141556-solved-function-creation-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.