[PHP] Question on syntax...

2003-08-20 Thread Jonathan Villa
I've seen this a few times in some code examples...

XXX::XXX

What do the 2 colons signify?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Question on syntax...

2003-08-20 Thread David Otton
On 20 Aug 2003 09:57:20 -0500, you wrote:

I've seen this a few times in some code examples...

XXX::XXX

What do the 2 colons signify?

Static method of an object.

Calling a method of a class without first instantiating an instance of the
class.

/* Class A has method B */
class A {
function B ($s = None) {
echo (p input : $s/p);
}
}

/* $C is an instance of A */
$C = new A ();

/* invoke A::B */
A::B ('call 1');

/* invoke $C-B */
$C-B ('call 2');


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Question regarding :: syntax

2002-06-03 Thread Jared Boelens

According to the CHM manual:

Sometimes it is useful to refer to functions and variables in base classes
or to refer to functions in classes that have not yet any instances.:

Using parent::foo() works fine but I am having problems getting the variable
part of this to work.
For Example:

class A {
var $b
A() {
  $b = something;
}
}

class B extends A {
B() {
echo parent::$b // this is the problem
}
}

Is there not a way to refer directly to the parent properties?  Or do i have
to setup a get function for every parent var that I want to access.

Thanks

-Jared


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] CHM Form Of PHP Manual? (Was: [PHP] Question regarding :: syntax)

2002-06-03 Thread Jason Teagle


- Original Message -
From: Jared Boelens [EMAIL PROTECTED]
To: php list [EMAIL PROTECTED]
Sent: Monday, June 03, 2002 5:06 PM
Subject: [PHP] Question regarding :: syntax


 According to the CHM manual:

There's a CHM form of a PHP manual? * bounce, bounce *Where could I get
it from? I find self-contained help files s much easier...


_ _
o oJason Teagle
   [EMAIL PROTECTED]
 v



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] CHM Form Of PHP Manual? (Was: [PHP] Question regarding :: syntax)

2002-06-03 Thread Jared Boelens

The CHM version of the help file can be downloaded here:

http://www.php.net/download-docs.php

-Jared
-Original Message-
From: Jason Teagle [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 03, 2002 12:16 PM
To: php list
Subject: [PHP] CHM Form Of PHP Manual? (Was: [PHP] Question regarding ::
syntax)



- Original Message -
From: Jared Boelens [EMAIL PROTECTED]
To: php list [EMAIL PROTECTED]
Sent: Monday, June 03, 2002 5:06 PM
Subject: [PHP] Question regarding :: syntax


 According to the CHM manual:

There's a CHM form of a PHP manual? * bounce, bounce *Where could I get
it from? I find self-contained help files s much easier...


_ _
o oJason Teagle
   [EMAIL PROTECTED]
 v



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Question regarding :: syntax

2002-06-03 Thread Tobyn Baugher

On Mon, 2002-06-03 at 12:06, Jared Boelens wrote:

 Is there not a way to refer directly to the parent properties?  Or do i have
 to setup a get function for every parent var that I want to access.

Tis my understanding that you cannot refer to class properties without
an instance of the class. If I were wrong it would make my life much
easier, but I don't believe I am.

Regards,

Toby



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] CHM Form Of PHP Manual? (Was: [PHP] Question regarding :: syntax)

2002-06-03 Thread Jason Teagle


- Original Message -
From: Jared Boelens [EMAIL PROTECTED]
To: php list [EMAIL PROTECTED]
Sent: Monday, June 03, 2002 5:20 PM
Subject: RE: [PHP] CHM Form Of PHP Manual? (Was: [PHP] Question regarding ::
syntax)


 The CHM version of the help file can be downloaded here:

 http://www.php.net/download-docs.php

Hmmm... I swear I tried downloading that version (English) before and it
didn't work - but it is fine this time. Thanks.


_ _
o oJason Teagle
   [EMAIL PROTECTED]
 v



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Question regarding :: syntax

2002-06-03 Thread Jared Boelens

So am i to understand that i will have to do it in this manner?


class A {
var $b;
A() {
}

function getB() {
return $this-B;
}
function setB($b) {
$this-B = $b;
}
}

class B extends A {
B($b) {
parent::setB($b);
}
}

$B = new B();
echo $B-getB();

This means writing a get and set function for every property that belongs to
the parent. I understand this is how it is done in other languages but the
manual is misleading in this case.  It explicity says Sometimes it is
useful to refer to functions and variables...  This lead me to believe that
you could directly access VARIABLES as well as functions.  I guess i was
wrong.  Oh well, it just means more typing for me, which means more hours,
which means more $.

-Jared


-Original Message-
From: Tobyn Baugher [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 03, 2002 12:30 PM
To: php list
Subject: Re: [PHP] Question regarding :: syntax


On Mon, 2002-06-03 at 12:06, Jared Boelens wrote:

 Is there not a way to refer directly to the parent properties?  Or do i
have
 to setup a get function for every parent var that I want to access.

Tis my understanding that you cannot refer to class properties without
an instance of the class. If I were wrong it would make my life much
easier, but I don't believe I am.

Regards,

Toby



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Question regarding :: syntax

2002-06-03 Thread Tobyn Baugher

On Mon, 2002-06-03 at 12:45, Jared Boelens wrote:
 So am i to understand that i will have to do it in this manner?

*SNIP*

No no no... B extends A, and you have an instance of B. Just do this:

class A
{
var $b;

*snip*
}

class B
{
function B($b)
{
$this-b = $b;
}
}

That will work fine.

Regards,

Toby


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Question regarding :: syntax

2002-06-03 Thread Jared Boelens

This may be a dumb question but, how can you be sure that the $this- is
referring to the parent classes' property and not the current class.  On
that note, does it really matter of which one it refers?

-Jared

-Original Message-
From: Tobyn Baugher [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 03, 2002 12:58 PM
To: php list
Subject: RE: [PHP] Question regarding :: syntax


On Mon, 2002-06-03 at 12:45, Jared Boelens wrote:
 So am i to understand that i will have to do it in this manner?

*SNIP*

No no no... B extends A, and you have an instance of B. Just do this:

class A
{
var $b;

*snip*
}

class B
{
function B($b)
{
$this-b = $b;
}
}

That will work fine.

Regards,

Toby


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Question regarding :: syntax

2002-06-03 Thread Tobyn Baugher

On Mon, 2002-06-03 at 13:42, Jared Boelens wrote:
 This may be a dumb question but, how can you be sure that the $this- is
 referring to the parent classes' property and not the current class.  On
 that note, does it really matter of which one it refers?

B inherits $b from A. $this-b and parent-b are the exact same thing.
This is why there's no special syntax to access parent-b from PHP.

Toby


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Question regarding :: syntax

2002-06-03 Thread Jared Boelens

That is exactly what I thought, I was just looking for some reassurance.  I
have been working with C# lately and the syntax  for classes is a lot more
explicit.  I wanted to make sure I wasn't making a mistake on what PHP
implcitly does.

Thanks

-Jared

-Original Message-
From: Tobyn Baugher [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 03, 2002 1:58 PM
To: php list
Subject: RE: [PHP] Question regarding :: syntax


On Mon, 2002-06-03 at 13:42, Jared Boelens wrote:
 This may be a dumb question but, how can you be sure that the $this- is
 referring to the parent classes' property and not the current class.  On
 that note, does it really matter of which one it refers?

B inherits $b from A. $this-b and parent-b are the exact same thing.
This is why there's no special syntax to access parent-b from PHP.

Toby


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php