•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,817 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,605 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 244 | Replies: 4
![]() |
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
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
Hunters Never Hurt
<?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";
function display()
{
echo "hello<br>";
}
while($i<=5)
{
display();
$i++;
}
?>//save this file and include this file in other file using include"filename.php";
Last edited by jino : Mar 19th, 2008 at 2:38 am. Reason: Want to make it more clear
We only have to do a very few things right in our life, so long as we don't do too many things wrong.
•
•
Join Date: Aug 2006
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
If you only want it to show once just use something like
...
if($has_not_displayed)
{
display();
$has_not_displayed = FALSE;
}
... Last edited by ha1f : Mar 19th, 2008 at 3:02 am.
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
Hunters Never Hurt
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Other Threads in the PHP Forum
- Previous Thread: pass the javascript variable to php page
- Next Thread: How i can do?


Linear Mode