You are here: Re: Calling scripts « All PHP « IT news, forums, messages
Re: Calling scripts

Posted by Johnny on 09/21/06 19:06

"d43m0n AT shaw DOT ca" <barryd.it@gmail.com> wrote in message
news:1158851673.543000.13100@m7g2000cwm.googlegroups.com...
>
> kenoli wrote:
> > I'm interested in the correct way to do two things:
> >
> > 1. Stop executing a script and begin executing it again from the top.
> > (i.e. go back to the top of the .php file you are in and start over as
> > if you had called the file for the first time, realizing some variables
> > may need to be reset.)
> >
> > 2. Stop executing a script and start executing a script in another
> > .php file.
> >
> > I'm not sure include() is the way to do this. I am not looking to
> > insert a script in an existing script but to exit one script and either
> > start it over or begin executing another one. I don't want the action
> > sent back to the first script at the end of the execution of the
> > second. I'm not sure how an include works exactly in this respect. I
> > think of it more as inserting code into some other code rather than as
> > sending the action elsewhere.
> >
> > The only other way I can see to do this is to use the header()
> > function, but this can't be done once html has been sent to the
> > browser. I've never fully understood this function or understood how
> > this limitation works.
> >
> > It is obvious how to do this when some user action is involved like a
> > form action or link selection. I am talking about how to do this as an
> > action from within a script where, for instance, a conditional like a
> > switch or something needs to send the action to the top of the same
> > script or to another .php file.
> >
> > --Kenoli
>
> To execute a new script, or to reproduce the results of your script
> there are many ways. First you have to determin what you want to
> acomplish.
>
> I personally am a command/terminal programmer, I like seeing my results
> come through a shell, rather then preprocess through http, as in a "web
> site". Now, to get to the point, the best way to look at php is like
> looking at any other language. Variables are your best freind, and can
> do more then just define foo=bar. To reproduce results, with previous
> results, you need to use variables to its fullest. Define functions to
> use multiple times or later on in your script. Too loop your script,
> that means to start a funtion, and then restart the funtion from the
> start to reprocess your data and reexecute the functions.
>
> Here is an example:
>
> <?php
> $loop = NULL;
> $bar = true; // Assigns the global variable $bar to the boolean value
'true', which retutrns 1.
> $foo = &$bar; // Forces and destroys $bar, and transfers its value to
$foo.
>
> while($foo) {
> usleep('1000000');
> echo 'Hello world' . "\n";
> if (($loop++) <= 10) {
> $foo = false;
> }
> }
> ?>
>
> This code is a bit elaberate, but it has a purpose. Notice how I
> defined $loop as null, and then defined $loop after the echo function,
> thus causing echo to return 11 echo's, before defining $foo as false,
> stoping the loop.
>

two things:
that will only echo 'Hello world' once not 11 times; and
$bar is NOT destroyed by $foo = &$bar;
instead a reference to $bar is created and $bar still exists with both $bar
and $fo returning the exact same contents.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация