PHP reference classes and load classes, cloning

Source: Internet
Author: User

Class Ren {public $name; public $sex; function __construct ($n, $s) {$this->name = $n;    $this->sex = $s; } function __clone () {$this->name = "John Doe";//this represents the Replica object $this->sex = "Lisi";//this represents the original, then discards}} $r = new Re N ("Zhang San", "male"); Clone $r 1 = Clone $r;

Var_dump ($R); Var_dump ($r 1); Reference class, Load class//About root path: Php inside/representing root path: refers to the disk where the file resides such as d;///html inside/Represents the root path: refers to the server folder: www//include//include//include ("/wamp/www/06  07/ren.class.php ");  Include "Ren.class.php";  Require "(Ren.class.php");  Require "(Ren.class.php");  Require_once "(Ren.class.php");  Require_once "(Ren.class.php");    "/"; /*//automatically loads class//1. All class file naming requires the same rule//2. The name must have a class name//3. All class files must be in the same folder

Function__autoload ($classname) {require $classname. ".   Class.php "; } $r = new Ren (); Echo $r->name; */

PHP reference classes and load classes, cloning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.