You are here: Re: How to open another page by PHP « All PHP « IT news, forums, messages
Re: How to open another page by PHP

Posted by J.O. Aho on 02/02/06 17:18

Stefan Mueller wrote:
>> if (!$_SESSION['my_session_variableberechtigung']) //not set
>> {
>> include('login.php');
>> }
>> else
>> {
>> whatever
>> }
>
> Good idea, but does 'include' not include the whole file before it starts
> executing the code?
> If yes it would mean that each file would be include before it starts
> executing.

No, PHP is executed from top to bottom, it will only include those pages it's
told to include depending on the condition. In your switch example, there
would be at most one file included (no default, so there can be time no file
is included).


> And my second concern is that it's not working if the file name is not
> defined at the beginning.
>
> <?php
> ...
> $my_application = "file" . $my_var;
> ...
> include($my_application);
> ...
> ?>

There are many who uses dynamically included files, take a look at phpnuke for
one example, I'm not that much for this, so you have to look this up yourself.


> I think regarding these two statements
> header("Location: login.php");
> resp.
> header("Location: file" . $my_var);
> would be the better choice.
>
> Or am I wrong?

Much depends on how you want things to work, you know freedom.


> Is there really no command which executes another PHP file just in time?

$thewholeresult=shell_exec('php yourphpfile.php');

but include is a lot better, as you can easily get the variables you got to
the main page to the included file, which is a little bit more tricky with
header() or execute another php file through a shell.


//Aho

 

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

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