A
A
Alexander Miranovich2018-02-20 18:35:39
PHP
Alexander Miranovich, 2018-02-20 18:35:39

How to run one file from another?

There are two files, you just need to run the other from one so that it also works, but not include, not in this file.
ps
I'm not strong in php, so maybe a stupid question, I have a php file, it performs some actions writes data to the session, another file is in a different place, which should record from this session, at the same moment, move them no, there is no possibility to execute one in the other, include is not suitable, the other has no rights in this section. Is there any easy way to run one file from another?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
synapse_people, 2018-02-20
@synapse_people

shell_exec + su/sudo + /usr/bin/php /path/to/script.php
?

F
fomenko_alexandr, 2018-02-20
@fomenko_alexandr

Can do

file_get_contents('http://yoursite.loc/yourscript.php');
//тут нужно вписать адрес, по которому находится желаемый скрипт

And the script on this page will work

L
Lone Ice, 2018-02-20
@daemonhk

At the end of the first script put header("Location: let_before_second_script"); The first one will execute and start the second one. Only one condition - there should be no html output.

A
Alexander, 2018-02-20
@AK-VoronM

$php_file = "path/to/file/filename";
$cmd = "nohup nice -19 php {$php_file} > /dev/null 2>&1 &";
exec($cmd);

This code will execute the file and continue its work without waiting for the command to be executed. Errors and output of the file being run will be removed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question