Thank you very much Matthew! It's ok.

Good night,
Matteo

On Mar 15, 12:37 pm, "Matthew Peters"
<[EMAIL PROTECTED]> wrote:
> Hi mbertazz,
>
> Well, it was solved pretty simply by putting
> require_once('config.php') at the top of pippo.php, before the include
> for SCA.php.
>
> When pippo.php gets called as the target of a web service request, the
> lines of code at the top of pippo.php are running at the very top
> level, so config.php gets to run in the environment it expects, where
> variables are global.
>
> So just make the top of pippo.php look like this:
>
> <?php
> /* pippo.php */
>
> require_once('config.php');
>
> include "SCA/SCA.php";
>
> .../...
> ?>
>
> Let me know how you get on.
>
> Matthew
>
> On Mar 14, 5:52 pm, "mbertazz" <[EMAIL PROTECTED]> wrote:
>
>
>
> > hi Matthew,
> > thank you very much for your help.
>
> > > I haven't checked what will happen when we use the pippo.php as the
> > > target of a webservice call, when it will be being called at the top
> > > level again. I will try that tomorrow.
>
> > yes, this is the real problem i found: i'm calling it as the target of
> > a webservice call.
>
> > thank you again,
> > mbertazz
>
> > On Mar 14, 6:24 pm, "Matthew Peters" <[EMAIL PROTECTED]>
> > wrote:> Hi mbertazz,
> > > This is a tricky little problem. The essence of the problem is that
> > > config.php only expects to find itself called from the very top level
> > > script, where all variables are global. That is why it does not bother
> > > to do global $CFG itself. However, when we call pippo.php for the
> > > first time e.g. from a client script like:
> > > <?php
> > >   /* client.php */
> > >   include_once('SCA/SCA.php');
> > >   $s = SCA::getService('pippo.php');
> > >   echo $s->m1('a','b');
> > > ?>
>
> > > then the require_once(config.php) is being called from a script that
> > > is already several calls down from in the call stack.
>
> > > The following fix works for calling the component locally:
> > > <?php
> > >   /* client.php */
> > >   require_once('config.php');
> > >   include_once('SCA/SCA.php');
> > >   $s = SCA::getService('pippo.php');
> > >   echo $s->m1('a','b');
> > > ?>
>
> > > whihc gets the call to config.php done nice and early.
>
> > > I haven't checked what will happen when we use the pippo.php as the
> > > target of a webservice call, when it will be being called at the top
> > > level again. I will try that tomorrow.
>
> > > Hope that helps,
> > > Matthew
>
> > > On Mar 14, 12:27 am, "mbertazz" <[EMAIL PROTECTED]> wrote:
>
> > > > Hi everybody,
> > > > to be clear i will explain my problem using the code below.
>
> > > > My problem is: when i use "m1" i obtain this error:
>
> > > > [Wed Mar 14 01:20:37 2007] [error] PHP Notice:  Fatal: CFG is not
> > > > configured! Exiting. in /home/messe318/setup.php on line 93
> > > > /home/messe318/setup.php(93) : Notice - Fatal: CFG is not configured!
> > > > Exiting.
>
> > > > why "global $CFG" doesn't wok into setup.php using SCA (if i call
> > > > setup.php directly it work) ?
>
> > > > the problem is i can't change config.php and setup.php, i can chage
> > > > pluto.php and pippo.php.
>
> > > > thank you in advance.
> > > > mbertazz
>
> > > > <?php
> > > > /* pippo.php */
>
> > > > include "SCA/SCA.php";
>
> > > > /**
> > > >  *
> > > >  * @service
> > > >  * @binding.ws
> > > >  *
> > > >  */
> > > > class pippo
> > > > {
>
> > > >         /**
> > > >          *
> > > >          * @reference
> > > >          * @binding.php Pluto.php
> > > >          */
> > > >          public $pluto;
>
> > > >         /**
> > > >          *
> > > >          * @param string $a
> > > >          * @param string $b
> > > >          * @return string
> > > >          */
> > > >         function m1($a,$b){
> > > >                 return $this->pluto->m2($a,$b);
> > > >         }}
>
> > > > ?>
>
> > > > <?php
> > > > /* Pluto.php */
>
> > > > require_once('config.php');
>
> > > > class Pluto
> > > > {
> > > >         function m2($a, $b){
> > > >                 global $CFG;
> > > >                 m3();
> > > >                 return $a.$b;
> > > >         }}
>
> > > > ?>
>
> > > > <?php
> > > > /* config.php */
>
> > > > unset($CFG);
>
> > > > $CFG->k    = '123';
> > > > $CFG->z    = '456';
>
> > > > require_once("setup.php");
> > > > ?>
>
> > > > <?php
> > > > /* setup.php */
>
> > > > global $CFG;
>
> > > > if (!isset($CFG->k)) {
> > > >         trigger_error('Fatal: CFG is not configured! Exiting.');
> > > >         die;
> > > >     }
>
> > > > function m3()
> > > > ...
> > > > ?>- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"phpsoa" group.
To post to this group, send email to phpsoa@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.co.uk/group/phpsoa?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to