[PHP] Extract variable out of a Class - Function
I have a function within a class. There is a variable inside that function which I need to access use outside of the class/function. For example ... Class Test { function showOutput { if ($this-url) { $justTT = substr($this-url,-10,7); echo $justTT; } } } I need to use $justTT. How do I get the value of $justTT into a different variable outside of this class/function so I can use it in a different class? --- Rahul S. Johari Supervisor, Internet Administration Informed Sources, Inc. [Email] ra...@troyjobs.com [Web] https://www.informed-sources.com [Phone] 518-687-6700 Ext: 154 [Fax] 518-687-6799 --- Rahul Sitaram Johari Founder, Internet Architects Group, Inc. [Email] sleepwal...@rahulsjohari.com [Web] http://www.rahulsjohari.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Extract variable out of a Class - Function
I have a function within a class. There is a variable inside that function which I need to access use outside of the class/function. For example ... Class Test { function showOutput { if ($this-url) { $justTT = substr($this-url,-10,7); echo $justTT; } } } I need to use $justTT. How do I get the value of $justTT into a different variable outside of this class/function so I can use it in a different class? Return it? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] Extract variable out of a Class - Function
Yes!!! It works!! Thats' exactly what I was looking for ... getting the value of $justTT in $othervar. I'm new to classes ... thus the noobity! On Apr 23, 2009, at 2:04 PM, Jônatas Zechim wrote: Class Test { function showOutput { if ($this-url) { $this-justTT = substr($this-url,-10,7); } } } $myvar=new Test(); $myvar-showOutput(); $othervar=$myvar-justTT; echo $othervar; $otherClass=new anotherclass($othervar); Is that u want? Zechim SP/Brazil -Mensagem original- De: Rahul S. Johari [mailto:sleepwal...@rahulsjohari.com] Enviada em: quinta-feira, 23 de abril de 2009 14:56 Para: php-general@lists.php.net Assunto: [PHP] Extract variable out of a Class - Function I have a function within a class. There is a variable inside that function which I need to access use outside of the class/function. For example ... Class Test { function showOutput { if ($this-url) { $justTT = substr($this-url,-10,7); echo $justTT; } } } I need to use $justTT. How do I get the value of $justTT into a different variable outside of this class/function so I can use it in a different class? --- Rahul Sitaram Johari Founder, Internet Architects Group, Inc. [Email] sleepwal...@rahulsjohari.com [Web] http://www.rahulsjohari.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php