php-windows Digest 5 May 2010 06:30:27 -0000 Issue 3803

Topics (messages 30070 through 30073):

Re: how to access class members
        30070 by: Richard Quadling
        30071 by: Ferenc Kovacs
        30072 by: Sascha Meyer

using php apc functions
        30073 by: Alexander Schunk

Administrivia:

To subscribe to the digest, e-mail:
        php-windows-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-windows-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-wind...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On 4 May 2010 14:02, Alexander Schunk <asch...@gmail.com> wrote:
> Hello,
>
> i have a question:
>
> How to access class members?
>
> I have the following class definition:
>
> class Mitarbeiter{
>
>           public $name = 'meier';
>           public $alter = '50';
>           public $gehalt = '2000';
>           public $abteilung = 'programmierung';
>
>           function printMember(){
>              echo 'Name: ' . $this->public;
>              echo 'Alter: ' . $this->public;
>              echo 'Gehalt: ' . $this->public;
>              echo 'Abteilung: ' . $this->public;
>           }
>      }
>
> Now i want to access the public member with:
>
> $m = new Mitarbeiter();
> $m->printMember();
>
> When calling method printMember() i get an error "cannot access empty
> class member".
>
> I dont see why the class members are empty?
>
> Regards
> Alexander
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

echo $this->name;

public relates to the visibility of the property (public - can be seen
by all, protected - can only be seen by this class and sub-classes and
private - can only be seen by this class).

Read more about this at
http://docs.php.net/manual/en/language.oop5.visibility.php

-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
On Tue, May 4, 2010 at 3:02 PM, Alexander Schunk <asch...@gmail.com> wrote:

> Hello,
>
> i have a question:
>
> How to access class members?
>
> I have the following class definition:
>
> class Mitarbeiter{
>
>           public $name = 'meier';
>           public $alter = '50';
>           public $gehalt = '2000';
>           public $abteilung = 'programmierung';
>
>           function printMember(){
>              echo 'Name: ' . $this->public;
>              echo 'Alter: ' . $this->public;
>              echo 'Gehalt: ' . $this->public;
>              echo 'Abteilung: ' . $this->public;
>           }
>

this should be:
          function printMember(){
             echo 'Name: ' . $this->name;
             echo 'Alter: ' . $this->alter;
             echo 'Gehalt: ' . $this->gehalt;
             echo 'Abteilung: ' . $this->abteilung;
          }

Tyrael

--- End Message ---
--- Begin Message ---
Hi Alex,

Alex wrote:
> How to access class members?
>
> I have the following class definition:
>
as Richard pointed out, you were not pointing at the class member's name but to 
the visibility of the variable instead; to give you a start, this is how your 
class should look like (but I would really advise to have a look at Richard's 
link to get a better understanding of class usage and OOP):

[CODE]
class Mitarbeiter{
    // use private if you are using getter methods to access members
    private $name = 'meier';

    public $alter = '50';
    public $gehalt = '2000';
    public $abteilung = 'programmierung';

    function get_name (){
        return $this->name;
    }

    function printMember(){
        echo 'Name: ' . $this->name . "<br />;
        echo 'Alter: ' . $this->alter . "<br />";
        echo 'Gehalt: ' . $this->gehalt . "<br />;
        echo 'Abteilung: ' . $this->abteilung . "<br />;
    }
}

$m = new Mitarbeiter();
$m->printMember();

// this would fail, because I changed the visibility of member 'name' from
// public to private
print $m->name;
// use a getter method instead:
print $m->get_name();

// this would work because the visibility is public, member is accessible from 
outside of the class
print $m->alter;

[/CODE]

Regards,

Sascha

--------------------------------------------------
EE:  http://www.experts-exchange.com/M_761556.html
ZCE: http://www.zend.com/en/yellow-pages#show-ClientCandidateID=ZEND011290
-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

--- End Message ---
--- Begin Message ---
Hello,

i want to use the php APC Functions.

I am using xampp server and latest php.

The Windows dll for APC is in the extensions directory and the
extension is configured in the php.ini.

However, i still get an error that php does not find the fuction apc_add:

$myvar =  'hell world';
     $stored = apc_add('myvar',$myvar);

     if($stored){
       echo 'Variable wurde gecached';

     }
     else{
       echo 'Variable wurde nicht gecached';
     }

Thank you
Alexander

--- End Message ---

Reply via email to