i’m trying to call a PHP script from a SH script.
It’s easy, i receive the values from SH, but nothing is passed when i try to pass values from first PHP to other PHP using OOP.
Here’s the first PHP, it receive a simple call from a SH file than pass values by URL:
$controller = $_GET['c'];
$metodo = $_GET['m'];
$uniqueid = $_GET['uniqueid'];
$url = '../controllers/'.ucfirst($controller).'.controller.php';
include_once($url);
$controller = ucfirst($controller)."Controller";
$objeto = new $controller;
$dados = $_POST;
$objeto->dados = $dados;
$objeto->uniqueid = $uniqueid;
//CALL THE FUNCTION
$result = $objeto->$metodo($uniqueid);
//RETURN THE RESPONSE
echo $result;
And here i receive values passed to object:
(Here’s the problem, the values are empty)
include('../classes/Tarifacao.class.php');
class TarifacaoController{
public function Tarifa($uniqueid){
$obj_tarif = new Tarifacao;
$bilhete = $obj_tarif->BuscaUltimoBilhete($uniqueid);
echo $this->Imprime($bilhete,'BILHETE');
$uniqueid = $bilhete['uniqueid'];
echo $this->Imprime($uniqueid,'UNIQUEID');
intval($duracao = $bilhete['billsec']);
echo $this->Imprime($duracao,'DURAÇÃO');
...
Sorry, my english is so poor.
If you execute PHP from the command line, you cannot pass values like that.
You need to use the
$argvreserved variable: http://www.php.net/manual/en/reserved.variables.argv.phpYou can try something like this:
And execute the script like this from the shell: