Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: object self reference


Message #1 by "Joel Wickard" <jwickard@l...> on Tue, 26 Jun 2001 12:40:38 -0500
Well,

i sugest use the Apache variables such as:

-$SCRIPT_URL
- $SCRIPT_URI
- $HTTP_REFERER

You can include this variables on your class constructor and resolv your
problem. eg

<?php
 class ErrorBug {
    var  $urlError;
    var $queryError;

   function bugReport () {
      $this->urlError = $HTTP_REFERER;
      $this->queryError = query_error;
   }

   --- Your objects methods... -----

 }
 }?>

Good luck!!

Luis Morales


Joel Wickard wrote:

> Luis,
> Thanks for your response,
> but that doesn't save me any more work than what I was doing in the first
> place.  I was hoping for some predefined PHP variable that I could use in
> the call so that I wouldn't have to type strings into the call at all... for
> example, I use $PHP_SELF for the $urlerror value, so that I don't have to
> type a new url on every page.  My hope was to have a global php variable
> that would equal the instance name of the object I was making the call from.
>
> ----- Original Message -----
> From: "LUIS M MORALES" <luismorales@j...>
> To: "professional php" <pro_php@p...>
> Sent: Monday, June 25, 2001 1:44 PM
> Subject: [pro_php] Re: object self reference
>
> >
> > Well,
> >
> > if you change the class contructor  may be work,
> >
> > eg.
> >
> > $query_results  = new bugReport ("main_switchboard.phtml", "query_error");
> >
> > and in your class  ErrorBug you put...
> >
> > <?php
> > class ErrorBug {
> >    var $urlError;
> >    var $queryError;
> >
> >   function bugReport ($urlError, $queryError {
> >      $this->urlError = $urlError;
> >      $this->queryError = $queryError;
> >   }
> >
> >   --- Your objects methods... -----
> >
> > }
> > }?>
> >
> >
> > Good luck!
> >
> > Luis Morales
> >
> > Joel Wickard wrote:
> >
> > > Hello everyone,
> > >
> > > I have an object with a method that I want to pass two arguments to. the
> > > code looks like this:
> > >
> > > $query_results = mysql_query($task_query);
> > >  if(!$query_results)
> > >  {
> > >        $query_error = new bug_report();
> > >         $query_error->error_report("main_switchboard.phtml",
> "query_error");
> > >  }
> > >
> > > I'd like to dynamically pass the name of the instance of the bug_report
> > > object.
> > > can I do this with statement like:
> > >
> > > $query_error = bug_report();
> > > $query_error->error_report("main_switchboard.phtml", $query_error->this)
> > >
> > > or something to that effect
> > >
> > > I hope that makes sense

  Return to Index