Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,152,795 members, 7,817,293 topics. Date: Saturday, 04 May 2024 at 09:45 AM |
Nairaland Forum / Science/Technology / Webmasters / Pls Help Me Convert Ths Code To OOP (520 Views)
Please Help Me With Php Code To Submit Picture To Database / Javascript Code To Make Rolling Banners/images / Moving To Oop Javascript/php Class Module Creation & Instantiation (2) (3) (4)
Pls Help Me Convert Ths Code To OOP by cbrass(m): 1:25pm On Dec 24, 2014 |
?php $a=1; $b=2; $c=$a+$b; Echo $c; ? Place help a dull boy Thanks |
Re: Pls Help Me Convert Ths Code To OOP by bot101(m): 3:35pm On Dec 24, 2014 |
<?php class myObj{ private $a; private $b; public function myObj($aa, $bb){ $this->a = $aa; $this->b = $bb; } public function echoSum(){ echo $this->a+$this->b; } } //This is one of many ways to do this, although not the best way cos i know better and shorter methods(just using this to illustrate oop concepts). //To use this class, you only need two lines of code $thisObject = new myObj(1,2); //creates and instantiates a new myObj object $thisObject->echoSum(); //echoes the sum of both numbers passed to the myObj constructor ?> 1 Like |
Re: Pls Help Me Convert Ths Code To OOP by cbrass(m): 7:40pm On Dec 24, 2014 |
Thanks slot bot101 pls is that "private" a keyword |
Re: Pls Help Me Convert Ths Code To OOP by dwebdesign(m): 8:17pm On Dec 24, 2014 |
yeah, in OOP, you can make an object "private" so it can only be accessed inside a function and not be able to be called outside the function. "private" is a keyword, syntax. mobile: 08133884165 WhatsApp: 08133884165 BBM: 2BB63350 http://www.1st-websitedesign.com |
(1) (Reply)
How To Get An Approved Adsense Account Within 3 Weeks / Pls I Need Help / You Help Is Urgently In Need
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 9 |