p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: address of object property inside another object


Message #1 by spam@k... on Sat, 21 Sep 2002 16:17:08 -0500
On php.net it says this: 
"Just like with directories where you'll have to type the full pathname in order to reach each file from the toplevel directory, you
have to specify the complete name of the function you want to call: In PHP terms, the toplevel directory would be the global
namespace, and the pathname separator would be ->. Thus, the names $cart->items and $another_cart->items name two different
variables."

I also notice in some code I'm reading this line: 

$this->db->query

This is in a security class that's using an object based on a db class it's included(). I take it you can't just write

$db->genericMethod

or

$db->anyProperty

if you want to use the db object that this security class is using, you have to refer to it as 

$this->db->genericMethod

???

This seems to me to be almost the opposite of what the above paragraph argues, since that is not at all how you would write a
directory path in a file system. (If I want a file in the directory dbClass I don't start the address pointing to the directory of
the security class - hope you don't mind the strained metaphor, but they brought it up.) 

Am I way off on this? 








Message #2 by "Nikolai Devereaux" <yomama@u...> on Mon, 23 Sep 2002 12:09:25 -0700
Maybe this will help keep things in perspective with your directory/filesystem
analogy:

using $this->db->property and $this->db->method is like using ./ to begin a
path.

$db isn't a variable in the function scope you're in.  That's different from
C++ and Java where member variable names are in scope in all member functions.

C++ and Java work kind of like your filesystem, then.

If you're in your home dir, and you have a program, 'method', ~/db/, you can
run it from the command line like this:

db/method


However, in PHP, you need to provide a more tangible start directory, like
this:

./db/method  or   ~/db/method

~ evaluates to your home dir, and therefore is an alternate (and appropriate)
analogy for $this.


Hope this helps!!

nik

Message #3 by "Grantham, Jeff" <JGrantham@m...> on Mon, 23 Sep 2002 14:26:11 -0500
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Say I had a file called update_wwv. This file runs lynx and pulls
data and puts it in another text file, which my page then pulls from
and inserts into the page. Right now I can only get it to run
manually from the command line. How can I get it to run via the page?
I am trying the following:
<?
	System("~/www/update_wwv");
?>

Why is this not working? Any ideas?

- -----Original Message-----
From: Nikolai Devereaux [mailto:yomama@u...] 
Sent: Monday, September 23, 2002 2:09 PM
To: beginning php
Subject: [beginning_php] RE: address of object property inside
another object


Maybe this will help keep things in perspective with your
directory/filesystem
analogy:

using $this->db->property and $this->db->method is like using ./ to
begin a
path.

$db isn't a variable in the function scope you're in.  That's
different from
C++ and Java where member variable names are in scope in all member
functions.

C++ and Java work kind of like your filesystem, then.

If you're in your home dir, and you have a program, 'method', ~/db/,
you can
run it from the command line like this:

db/method


However, in PHP, you need to provide a more tangible start directory,
like
this:

./db/method  or   ~/db/method

~ evaluates to your home dir, and therefore is an alternate (and
appropriate)
analogy for $this.


Hope this helps!!

nik


- ---

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPY9q0X87SZaA9EEEEQJCiwCg+xbwTzJgMHtjLsJQBacdsLk3C64AoPeA
FzQDLYeM126cSVMQc9wmDLsE
=CKGd
-----END PGP SIGNATURE-----


                    Confidentiality Statement 
"The information contained in this electronic message is attorney privileged
and confidential information intended only for the use of the owner of the
email address listed as the recipient of this message.  If you are not the
intended recipient, or the employee or agent responsible for delivering this
message to the intended recipient, you are hereby notified that any
disclosure, dissemination, distribution, or copying of this communication is
strictly prohibited.  If you have received this transmission in error,
please immediately notify us by telephone at  xxx-xxx-xxxx  and return the
original message to us at McGlinchey Stafford*643 Magazine St.*New
Orleans,*LA*70130 via the United States Postal Service."


Message #4 by "Nikolai Devereaux" <yomama@u...> on Mon, 23 Sep 2002 13:32:33 -0700
Well, the ~ is suspect here... when you request the page of the webserver, ~ is
the home directory of the webserver user, typically "nobody" or "www".  You
need to make sure that the update_wwv program is in the correct directory, that
the webserver user has the permission to execute it.


Take care,

nik

Message #5 by "Grantham, Jeff" <JGrantham@m...> on Mon, 23 Sep 2002 15:35:35 -0500
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I have tried it with the ~ and with the /home/user/www path. I am
using phpwebhosting.com and can not figure out why it won't run.

- -----Original Message-----
From: Nikolai Devereaux [mailto:yomama@u...] 
Sent: Monday, September 23, 2002 3:33 PM
To: beginning php
Subject: [beginning_php] RE: address of object property inside
another object


Well, the ~ is suspect here... when you request the page of the
webserver, ~ is
the home directory of the webserver user, typically "nobody" or
"www".  You
need to make sure that the update_wwv program is in the correct
directory, that
the webserver user has the permission to execute it.


Take care,

nik


- ---

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPY97F387SZaA9EEEEQK+lwCePyWxsU8W/JkI34nL3k5z26I02q8Ani4U
WDWv0+lklfTUbMS/NVB8VmcH
=4NUx
-----END PGP SIGNATURE-----


                    Confidentiality Statement 
"The information contained in this electronic message is attorney privileged
and confidential information intended only for the use of the owner of the
email address listed as the recipient of this message.  If you are not the
intended recipient, or the employee or agent responsible for delivering this
message to the intended recipient, you are hereby notified that any
disclosure, dissemination, distribution, or copying of this communication is
strictly prohibited.  If you have received this transmission in error,
please immediately notify us by telephone at  xxx-xxx-xxxx  and return the
original message to us at McGlinchey Stafford*643 Magazine St.*New
Orleans,*LA*70130 via the United States Postal Service."


Message #6 by "Nikolai Devereaux" <yomama@u...> on Mon, 23 Sep 2002 13:45:33 -0700
> I have tried it with the ~ and with the /home/user/www path. I am
> using phpwebhosting.com and can not figure out why it won't run.

I can't think of anything other than permissions, then... sorry I can't be of
more help in this situation...


nik


  Return to Index