例1,绘制一个圆形
header ("Content-type: image/png");
$im = ImageCreate (150, 150);
$grey = ImageColorAllocate ($im, 230, 230, 230);
$black = ImageColorAllocate ($im, 0, 0, 0);
ImageString($im, 3, 5, 5, "Figure 18.5: Circle", $black);
ImageArc($im, 75, 75, 50, 50, 0, 360, $black);
ImagePng ($im);
ImageDestroy ($im);
?>
例2,绘制圆形 Drawing a Circle with imagearc()
header("Content-type: image/png");
$image = imagecreate( 200, 200 );
$red = imagecolorallocate($image, 255,0,0);
$blue = imagecolorallocate($image, 0,0,255 );
imagearc( $image, 99, 99, 180, 180, 0, 360, $blue );
imagefill( $image, 99, 99, $blue );
imagepng($image);
?>
php抽象类的实例代码,如下:
<?php
/**
* 定义与使用php抽象类
* edit: www.
*/
abstract class Number {
private $value;
abstract public function value();
public function reset() {
$this->value = NULL;
}
}
class Integer extends Number {
private $value;
public function value() {
return (int)$this->value;
}
}
$num = new Integer; /* Okay */
$num2 = new Number; /* This will fail */
?>
例1,在php类中定义常量
class Employee {
//定义常量
const AVAILABLE = 0;
const OUT_OF_STOCK = 1;
public $status;
}
print Employee::AVAILABLE;
?>
例2,定义类中的常量
<?php
class math_functions {
//定义常量
const PI = '3.14159265';
const E = '2.7182818284';
const EULER = '0.5772156649';
/* 在这里定义其它的常量与方法... */
}
echo math_functions::PI;
?>