FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


PHP running PHP





eudbase
Hi, I need to run a PHP file from another PHP file automaticly in the server. Is it possible to do that? Usually we run PHP by using browser right? What I need here is to run a PHP file without being view or invoked from the browser. Much like calling a function, but now I am calling a PHP file to run hiddenly by using another control PHP file. Is it possible to do like that?
albuferque
What SAPI do you have?
If you don't know type php -v and it will tell you whether php is CGI or CLI.

If it's CLI, then there are many possibilities to accomplish your task.Telling PHP to execute a certain file.

php my_script.php

php -f my_script.php

Also you can use the "passthru function"

Check for more details:

http://www.php.net/passthru
erlendhg
Could you try to explain that more thoroughly?
Do you just want to include a php file without having it to output anything?
rvec
Code:
ob_start();
include('your_file.php');
ob_end_clean

That'll include a file and throw away all output.
riccopt
rvec wrote:
Code:
ob_start();
include('your_file.php');
ob_end_clean

That'll include a file and throw away all output.

that is what I was about to suggest....
it can even be called using @include() which will hide the error if it happens (file missing or other errors)...
eudbase
I have an PHP script which is a application that will create, modifiy an output file. I need it to be invoked from another PHP script/HTML script which can be browsed by user. The hidden "application PHP" is running in the server without showing to the user. Can it be done like that? I think php:passthru is what I need, I will have a try on it and see. Any other suggestion is welcome. Thanks a lot!
riccopt
eudbase wrote:
I have an PHP script which is a application that will create, modifiy an output file. I need it to be invoked from another PHP script/HTML script which can be browsed by user. The hidden "application PHP" is running in the server without showing to the user. Can it be done like that? I think php:passthru is what I need, I will have a try on it and see. Any other suggestion is welcome. Thanks a lot!
all you need to run a PHP file inside another PHP file is call it using the INCLUDE function... as already mentioned on the prevous replies...
albuferque
eudbase wrote:
... What I need here is to run a PHP file without being view or invoked from the browser. Much like calling a function, but now I am calling a PHP file to run hiddenly by using another control PHP file....


Well, include seems to be the logical answer BUT IT'S NOT. He needs something automatic and hidden, more like a batch background process.
rvec
why would he need that?
Quote:
I need to run a PHP file from another PHP file automaticly

The best way to do that would be include.

The other way would be to run it like you said before with exec('php -f file.php'), but it'd do just the same.
sonam
Quote:
He needs something automatic and hidden, more like a batch background process.


How I know php scripts are hidden and run on the server. No one can see the code or process and only results are printed out. If he don't want to allow anyone to run php directly in browser (and only allow include), this is absolutely different question. In that case he need to check PHP_SELF.

Sonam
Related topics
[tutor] How to protect images without htaccess using PHP
Make search engine With PHP and mySQL, for your site
ARRGG... Php can't Get to mySql
[PHP] Running Cron Jobs Via PHP Script
Which Linux distribution is the best?
Try method in php does not work
where to install php?
Apache/php running too slowly
Uploading an Image using PHP script - RESOLVED
ASP.NET
Apache/Php5/MySql = Complete Fustration
PHP Hangs On 2.2250738585072011e-308 (on some hardware)
"PHP is not running" while trying to install WordP
Wordpress: Php is not running
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.