Blogger Information
Blog 28
fans 0
comment 0
visits 16654
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
use导入命名空间且别名-2018年05月10日00:46
植树青年小江同志的博客
Original
415 people have browsed it

脚本1号

实例

<?php

namespace vehicle\Civic;

class Civic
{
  public $name = 'Civic';
  private $power = '177';

  public function __construct($name, $power)
  {
    $this->name = $name;
    $this->power = $power;
  }

  public function race($time='7')
  {
    echo '加速时间' . $time . 's';
  }

  
}

运行实例 »

点击 "运行实例" 按钮查看在线实例

脚本2号

实例

<?php


namespace vehicle\Fit;

require('Civic.php');

use vehicle\Civic\Civic as Civic;

class Fit extends Civic
{
  public $name = 'Fit';
  private $power = '131';

  public function __construct($name, $power)
  {
    $this->name = $name;
    $this->power = $power;

    $this->race('9');
  }
}

$newFit = new Fit('new Fit', '131');

echo '<hr/>';

echo $newFit->race('9');

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post