?php trait HelloWorld public function sayHello echo 'Hello World!'; class TheWorldIsNotEnough use HelloWorld; public function sayHello echo 'Hello Universe!'; $o = new TheWorldIsNotEnough; $o-sayHello; // echos Hello Universe! ? 呵呵,是不
sayHello(); // echos Hello Universe! ?>
呵呵,是不是有点像ruby 的多重继承(include?),呵呵,其实都差不多,这个功能不错,以后框架可以用到。PHP5.4以上的功能才支持哦!
原文地址:试用 PHP trait, 感谢原作者分享。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),