Create the class like such:

<?php

Class A
{
    var $id;

    function x ( $whatever )
    {
        // assign $id's value.
        $newval = $whatever++;
        $this->id = $newval;
    }
    //
    // Return the value of $id.
    //
    function getId ( )
    {
        return $this->id;
    }
}

?>

To retrieve this variable in another php script do this then:

<?php

    require ("example1.php");

    $news = new A();

    $news->x ( 5 );

    print ( "Value of id is ".$news->getId() ); // This will print out '6'.

?>

Cheers


> Hi guys!!
>
> Thnx a bunch, it worked out... I used the split function...
>
> Meanwhile, hv another question !!
>
> I hv a var $id declared within a function x of a class called A
>
> I need to access this var $id in another php file...
>
> I do the following:
>
> <?php
>
> require ("example1.php");
>
> $news = new A();
>
> // I want to something like this:      print ($news->A->$id);
>
> //print ($news->id); ?>
>
> How do i achieve this??
>
> Thanks again to all of u!!
>
> sands
>
>
> -----Original Message-----
> From: Neil Freeman [mailto:[EMAIL PROTECTED]]
> Sent: quinta-feira, 17 de Janeiro de 2002 12:41
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] string to array??
>
>
> You just have to remember that a string is simply a character array :)
>
> Nick Wilson wrote:
>
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > * On 17-01-02 at 12:57
> > * Steve Edberg said....
> >
> > > Actually, you can treat a string as an array without any further
> > > processing:
> > >
> > >       $Globbot = 'dribcot';
> > >       echo $Globbot[0];       # echoes 'd'
> > >       echo $Globbot[6];       # echoes 't'
> > >
> > > Check out 'String access by character' about halfway down the page at
> > >
> > >       http://www.php.net/manual/en/language.types.string.php
> > >
> > > (or, in Portuguese,
> > >
> > >       http://www.php.net/manual/pt_BR/language.types.string.php
> > >
> > >
> >
> > Hmmm..... I didn't know that!
> >
> > > Actually, using the [] syntax is deprecated - using {} is the new way
> > > - but I'm a creature of habit...
> > >
> >
> > Or that!
> >
> > - --
> >
> > Nick Wilson
> >
> > Tel:    +45 3325 0688
> > Fax:    +45 3325 0677
> > Web:    www.explodingnet.com
> >
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.0.6 (GNU/Linux)
> >
> > iD8DBQE8Rrz+HpvrrTa6L5oRAn4kAKCx41//DDBp/bPzPprs2Zls0xjGJgCgk5tz
> > x16a8iDFuzEmsgSg5Iv/8Ms=
> > =smoj
> > -----END PGP SIGNATURE-----
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> > ***************************************************************
> >  This message was virus checked with: SAVI 3.52
> >  last updated 8th January 2002
> > ***************************************************************
>
> --
> --------------------------------
>  Email:  [EMAIL PROTECTED]
>          [EMAIL PROTECTED]
> --------------------------------
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to