By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,347 Members | 1,390 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,347 IT Pros & Developers. It's quick & easy.

GLOBAL OBJECT IN EXEC COMMAND CALL

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Jimmy Jim wrote:
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

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.
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.