GLOBAL OBJECT IN EXEC COMMAND CALL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jimmy Jim

    GLOBAL OBJECT IN EXEC COMMAND CALL

    Hey all, quick question to see if anyone has any ideas. I have an
    object:

    $special = new special;

    Let's say I have a function:

    class special {
    function outputtext() {
    return "test";
    }
    }

    now let's say I want to use the exec command to output that text:

    exec("/usr/local/bin/php -r 'echo
    $special->outputtext();' ",$returnarray, $returnvar);

    I get an error call to a member function on a non-object.

    Any ideas how to pass teh GLOBAL OBJECT var into the shell exec
    command? I am haivng a terrible time figuring out what to do.

    THanks for any responses!

    JJ
  • Michael Austin

    #2
    Re: GLOBAL OBJECT IN EXEC COMMAND CALL

    Jimmy Jim wrote:
    [color=blue]
    > Hey all, quick question to see if anyone has any ideas. I have an
    > object:
    >
    > $special = new special;
    >
    > Let's say I have a function:
    >
    > class special {
    > function outputtext() {
    > return "test";
    > }
    > }
    >
    > now let's say I want to use the exec command to output that text:
    >
    > exec("/usr/local/bin/php -r 'echo
    > $special->outputtext();' ",$returnarray, $returnvar);
    >
    > I get an error call to a member function on a non-object.
    >
    > Any ideas how to pass teh GLOBAL OBJECT var into the shell exec
    > command? I am haivng a terrible time figuring out what to do.
    >
    > THanks for any responses!
    >
    > JJ[/color]


    It is redundant to call PHP from a "sub-process" to execute a PHP
    function that will return avalue to the same PHP script. there is no
    advantage to doing something like that. Your function must be local to
    the executing script. Global Object does not mean system global, it
    means script global. When you use exec or `` you are actually spawning a
    sub-process and expecting a result. The function in the calling program
    does not get transferred to the sub-process - unless the same PHP script
    is being executed in the sub-process. It is like running a program in
    windows that starts another program in DOS and expecting the routines in
    your windows program to be available to your DOS program.


    Michael Austin.


    Comment

    Working...