lucerias Posted November 14, 2006 Share Posted November 14, 2006 Below is the sample code of .php file, firstly, $CustomerClass is defined as a class called Customer, which is defined in Customer.php and then for $CustomerClass->Save(), i don't understand because Save() is a function inside Save.php file but not a function under Customer class, why we can define like that and what is the meaning of that? Thank you.require_once('include/Customer.php'); require_once('include/Save.php'); $CustomerClass = New Customer();$CustomerClass->Save(); Link to comment https://forums.phpfreaks.com/topic/27250-php-class-and-function/ Share on other sites More sharing options...
Caesar Posted November 14, 2006 Share Posted November 14, 2006 [code]<?php class myclass { function funkshun() { $currtime = time(); $currdate = date("M d, Y", $currtime); echo"$currdate"; } } $c = new myclass; $c->funkshun();?>[/code]Keep in mind, there are other methods, approaches, and options concerning OOP. I am trying to make the example as simplistic as possible. Hope that helps. Link to comment https://forums.phpfreaks.com/topic/27250-php-class-and-function/#findComment-124691 Share on other sites More sharing options...
lucerias Posted November 15, 2006 Author Share Posted November 15, 2006 I understand what you want to say, but you call a function belongs to its class, this is typical OO working principle and my question is how come the existing code i saw calls a function not belong to its class but under a different .php file. Thank you. Link to comment https://forums.phpfreaks.com/topic/27250-php-class-and-function/#findComment-124784 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.