i have a function

lets say
function myfunc()
{
echo 'hi';
}

now the code may call the function myfunc more than a time
but there should be only one time echo of 'hi'

pliz help anything could work .... but all my effort in vain
static variable ????
global variable checking ???
code in a separate file n making include_once ?????


pliz help

<?php 
function display()
{
    echo "hello<br>";
}
while($i<=5)
{
    display();
    $i++;
}
?>//save this file and include this file in other file using include"filename.php";

i said just a one ...

yes i will be call the function many time from different-different modules

But certain codes inside the function should execute just a once ..... not twice .. not five times....

thank you

If you only want it to show once just use something like

...
if($has_not_displayed)
{
  display();
  $has_not_displayed = FALSE;
}
...

:(

ok let me little clearly state my problem much in detail

there are 50 file that each contains display() function at-least at 10 diff places.


display function is in display.php (included by all 50 files)

now i need single execution of certain contains of display()..... i cant make conditions while calling the function .... i need to do some thing in common inside that function ...


Thanks for follow up ...
i know ... this could be done
through static var or globals or include_once
but i dont know y all of these are not working with me this time ....

i m little bg ... i will specify the code ...
i know somewhere i got mistake ... but i m not getting for identifying it ...
thank you once again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.