mysterbx Posted September 21, 2009 Share Posted September 21, 2009 Hello, i am try'ing to create a simple php file editing and dont know how to solve one thing... What i need, is to stop not show some html content to user and then continue showing Example: <? $stop=stop(); $continue=continue(); echo "Here is my content $stop // this content is not shown! $continue continuing to show my content"; ?> Output would look like: Here is my content continuing to show my content the function should be used with a variable, otherwise everyone knows how to do it this is the last peace of the puzzle im solving Quote Link to comment Share on other sites More sharing options...
ozestretch Posted September 21, 2009 Share Posted September 21, 2009 So you want to output html, then run some code, then output more html? Quote Link to comment Share on other sites More sharing options...
Bricktop Posted September 21, 2009 Share Posted September 21, 2009 Hi mysterbx, sleep() should do what you need, have a look at the manual for further info at http://www.php.net/manual/en/function.sleep.php. However, it isn't an ideal solution - and you may run into problems as the web server may buffer the script and output it all at once, you could try using; echo 'something'; ob_flush(); flush(); sleep(10); echo 'something else'; It might be worth looking at setTimeout() with Javascript (http://www.w3schools.com/JS/js_timing.asp). Hope this helps. Quote Link to comment Share on other sites More sharing options...
waynew Posted September 21, 2009 Share Posted September 21, 2009 <html> <head> <title>Example</title> </head> <body> <?php if($var == "foo"){ ?> <h1>Var is equal to foo</h1> <?php } else{ ?> <h1>Var is not equal to foo</h1> <?php } ?> </body> </html> Is that what you meant? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted September 21, 2009 Share Posted September 21, 2009 I think you want this ! <?php echo "Here is my content flush(); sleep(5); echo "continuing to show my content"; ?> if you want some user interaction then see JavaScript Quote Link to comment Share on other sites More sharing options...
ozestretch Posted September 21, 2009 Share Posted September 21, 2009 sleep() may, was vague on what "not show some html content to user" actually means If he still wants to display content, but only to selected users, then some form of authentication is required, if he wants to simply <?php echo '<div>here is some html to output</div>'; function here_is_some_code_to_run($aussie_chicks){ if($aussie_chicks != 'Hot'){ return false; }else{ return true; } } $blonde6footandbusty = here_is_some_code_to_run('Over Wieght Midget Monkey'); if(!$blonde6footandbusty){ require_once('a_bullet_to_the_head.php'); } echo '<div>here is some continued html to out put</div>'; ?> Then he has the right idea Quote Link to comment Share on other sites More sharing options...
mysterbx Posted September 21, 2009 Author Share Posted September 21, 2009 i meant to say, that i dont want to use any "IF's" or anything that is not a variable, im making a simple script, for users who only know html or js, so i want to make it as simple as it can be.. I will try the flush(); thing though will post something after i do Quote Link to comment Share on other sites More sharing options...
mysterbx Posted September 21, 2009 Author Share Posted September 21, 2009 found what i needed its ob_start("function"); does the job perfectly! thanks for helping! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.