gudfry Posted July 22, 2008 Share Posted July 22, 2008 hi to all; I wan to create a function to display the element. I have another way to able to understand. have a piece of code element.php function element(string) { string="name" //element of name string="age" // element of age } //end of my function the function that i have would be inserted in my index.php, i doing this way index.php <? include(element.php) $string='name'; $output=create_P($string); if (gettype($output)=="array") echo '<p>element: '.($output).'</p>'; else echo '<p>No string found accordoing to the difinition</p>'; <? i want to output the name and age but i think i got a wrong way to do. any idea?? Link to comment https://forums.phpfreaks.com/topic/115938-how-to-create-a-function-to-display-the-element/ Share on other sites More sharing options...
sader Posted July 22, 2008 Share Posted July 22, 2008 Your code it strange and messy, do you know how functions works, what is function parameter.. Example: <?php function print_me_nice($name, $age) { echo "<b>Name: </b>".$name."<br />"; echo "<b>Age: </b>".$age."<br />"; } //now use this function print_me_nice("John",26); print_me_nice("Peter",12); ?> Link to comment https://forums.phpfreaks.com/topic/115938-how-to-create-a-function-to-display-the-element/#findComment-596114 Share on other sites More sharing options...
gudfry Posted July 22, 2008 Author Share Posted July 22, 2008 well sory for that kind of question. actualy I am new in PHP so its hard for me to understand some php stuff. well thanks any we. Link to comment https://forums.phpfreaks.com/topic/115938-how-to-create-a-function-to-display-the-element/#findComment-596119 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.