07c03-1.php

来自「介绍PHP5的给类型函数应用」· PHP 代码 · 共 29 行

PHP
29
字号
<?php// Define our class for Compact disksclass cd {	// Declare variables (properties)	public $artist;	public $title;	protected $tracks;	private $disk_id;		// Declare the constructor	public function __construct() {		// Generate a random disk_id		$this->disk_id = sha1('cd' . time() . rand());	}	// Create a method to return the disk_id, it can't be accessed directly	// since it is declared as private.	public function get_disk_id() {		return $this->disk_id;	}}// Instantiate an object of class 'cd'.$mydisk = new cd();// Now use the provided function to retrieve, and display, the idecho '<p>The compact disk ID is: ', $mydisk->get_disk_id(), '</p>';?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?