conditional branching?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Is there any way in PHP of directing to a specific location?
When a user clicks on a button, I want the selected item to take the
programming to that area.

e.g. If buttonclicked="yes" then goto branchlabel-10.

I would prefer this NOT setup in a while or do while statement and function

Re: conditional branching?

richard wrote:
Quoted text here. Click to load it

Usually you'll be able to accomplish this with a switch, and personally
if I couldn't do it with a switch, I'd rethink how I was doing it.

I feel compelled to mention that as of PHP 5.3, 'goto' is available
( ) and you may
let the XKCD cartoon in the PHP docs speak to its usage.


Re: conditional branching?

richard schreef:
Quoted text here. Click to load it


Location as in linenumber? Or label?

Quoted text here. Click to load it

If that button is on a webpage in a browser, PHP is not involved.
PHP runs at the server and only delivers the HTML (or whatever output)
to the browser (or whatever client).

So the clicked button is, well, clicked in the browser. PHP is not there.
However, if that button happen to invoke a PHP script, it is up to you
to decide in that script what to do, most likely via reading one of the
superglobals $_GET or $_POST.

A button can invoke a PHP script by, eg:
Button happens to be the submit for a form in html that has the

Quoted text here. Click to load it

What does that mean? Where is that code supposed to run?
Are you talking serversire or clientside?
Clientside is typically handled by JavaScript.
Serverside (in this case) PHP.
They are NOT related in any way. PHP has NO CLUE what happens in the

Quoted text here. Click to load it

I have no clue what that means in this context.
You are NOT running PHP in loop to catch a browservent, that is simply

Two possibilities: I completely misinterpret your posting (that
happens), or you need to brush up your client-server knowledge a lot.
In both cases, feel free to come back, but be more clear. :-)

Erwin Moller

"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare

Site Timeline