Jump to content

how to create a function to display the element


gudfry

Recommended Posts

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??

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);
?>

 

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.