## 12345 ##6
7
#8
|
class first_class {
#use first_trait;
} #$obj #= new first_class();
$obj ->first_method(); ######// 有效的######<p class="line number8 index7 alt1" style="line-height:15.4px;margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;vertical-align:baseline;min-height:auto;white-space:pre;"><code class="php variable" style="margin:3px auto 0px;padding:0px 0px 0px 5px;background:rgb(255,255,255);border-left:3px solid rgb(108,226,108);font-size:14px;clear:both;border-top:0px;border-right:0px;border-bottom:0px;float:none;vertical-align:baseline;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;color:rgb(170,119,0);">$obj ->second_method(); ######// 有效的#######<p style="margin-bottom:0px;padding-top:5px;padding-bottom:5px;font-size:14px;line-height:30px;"><strong>使用多個Trait<br></strong></p>
<p style="margin-bottom:0px;padding-top:5px;padding-bottom:5px;font-size:14px;line-height:30px;">在同一個Class 中可以使用多個Trait</p>
<p class="toolbar" style="line-height:13.2px;margin:0px;padding:0px;background:rgb(108,226,108);border:none;float:none;vertical-align:baseline;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;color:#FFFFFF;"><span style="line-height:25.2px;">?</span></p>
<table border="0" style="border-spacing:0px;border:1px solid rgb(204,204,204);margin-top:.54em;text-align:center;clear:both;background:none;float:none;line-height:1.1em;margin-right:0px;margin-bottom:0px;margin-left:0px;padding:0px;vertical-align:baseline;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:1em;min-height:auto;">
<tbody style="background:none;float:none;line-height:1.1em;margin:0px;padding:0px;text-align:left;vertical-align:baseline;font-size:1em;min-height:auto;"><tr style="background:none;border-top:0px;float:none;line-height:1.1em;margin:0px;padding:0px;vertical-align:baseline;font-size:1em;min-height:auto;" class="firstRow">
<td class="gutter" style="padding:.2em .46em;border-color:rgb(204,204,204);margin:0px;background:none;float:none;line-height:1.1em;vertical-align:baseline;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:1em;min-height:auto;color:rgb(175,175,175);">
<p class="line number1 index0 alt2" style="line-height:15.4px;margin:0px;padding:0px .5em 0px 1em;background-image:none;border-width:0px 3px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;text-align:right;vertical-align:baseline;min-height:auto;white-space:pre;">1</p>
<p class="line number2 index1 alt1" style="line-height:15.4px;margin:0px;padding:0px .5em 0px 1em;background-image:none;border-width:0px 3px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;text-align:right;vertical-align:baseline;min-height:auto;white-space:pre;">2</p>
<p class="line number3 index2 alt2" style="line-height:15.4px;margin:0px;padding:0px .5em 0px 1em;background-image:none;border-width:0px 3px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;text-align:right;vertical-align:baseline;min-height:auto;white-space:pre;">3</p>
<p class="line number4 index3 alt1" style="line-height:15.4px;margin:0px;padding:0px .5em 0px 1em;background-image:none;border-width:0px 3px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;text-align:right;vertical-align:baseline;min-height:auto;white-space:pre;">4</p>
<p class="line number5 index4 alt2" style="line-height:15.4px;margin:0px;padding:0px .5em 0px 1em;background-image:none;border-width:0px 3px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;text-align:right;vertical-align:baseline;min-height:auto;white-space:pre;">#5</p>
<p class="line number6 index5 alt1" style="line-height:15.4px;margin:0px;padding:0px .5em 0px 1em;background-image:none;border-width:0px 3px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;text-align:right;vertical-align:baseline;min-height:auto;white-space:pre;">6</p>
<p class="line number7 index6 alt2" style="line-height:15.4px;margin:0px;padding:0px .5em 0px 1em;background-image:none;border-width:0px 3px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;text-align:right;vertical-align:baseline;min-height:auto;white-space:pre;">7</p>
<p class="line number8 index7 alt1" style="line-height:15.4px;margin:0px;padding:0px .5em 0px 1em;background-image:none;border-width:0px 3px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;text-align:right;vertical-align:baseline;min-height:auto;white-space:pre;">8</p>
<p class="line number9 index8 alt2" style="line-height:15.4px;margin:0px;padding:0px .5em 0px 1em;background-image:none;border-width:0px 3px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;text-align:right;vertical-align:baseline;min-height:auto;white-space:pre;">9</p>
<p class="line number10 index9 alt1" style="line-height:15.4px;margin:0px;padding:0px .5em 0px 1em;background-image:none;border-width:0px 3px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;text-align:right;vertical-align:baseline;min-height:auto;white-space:pre;">10</p>
<p class="line number11 index10 alt2" style="line-height:15.4px;margin:0px;padding:0px .5em 0px 1em;background-image:none;border-width:0px 3px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;text-align:right;vertical-align:baseline;min-height:auto;white-space:pre;">#11</p>
<p class="line number12 index11 alt1" style="line-height:15.4px;margin:0px;padding:0px .5em 0px 1em;background-image:none;border-width:0px 3px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;text-align:right;vertical-align:baseline;min-height:auto;white-space:pre;">12</p>
<p class="line number13 index12 alt2" style="line-height:15.4px;margin:0px;padding:0px .5em 0px 1em;background-image:none;border-width:0px 3px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;text-align:right;vertical-align:baseline;min-height:auto;white-space:pre;">13</p>
<p class="line number14 index13 alt1" style="line-height:15.4px;margin:0px;padding:0px .5em 0px 1em;background-image:none;border-width:0px 3px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;text-align:right;vertical-align:baseline;min-height:auto;white-space:pre;">14</p>
<p class="line number15 index14 alt2" style="line-height:15.4px;margin:0px;padding:0px .5em 0px 1em;background-image:none;border-width:0px 3px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;text-align:right;vertical-align:baseline;min-height:auto;white-space:pre;">15</p>
<p class="line number16 index15 alt1" style="line-height:15.4px;margin:0px;padding:0px .5em 0px 1em;background-image:none;border-width:0px 3px 0px 0px;border-right-style:solid;border-right-color:rgb(108,226,108);float:none;text-align:right;vertical-align:baseline;min-height:auto;white-space:pre;">16</p>
</td>
<td class="code" style="padding:.2em .46em;border-color:rgb(204,204,204);margin:0px;background:none;float:none;line-height:1.1em;vertical-align:baseline;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;font-size:1em;min-height:auto;">
<p class="container" style="line-height:15.4px;margin:0px;padding:0px;background:none;border:0px;float:none;vertical-align:baseline;min-height:auto;"><br></p>
<p class="line number1 index0 alt2" style="line-height:15.4px;margin:0px;padding:0px 1em;background-image:none;border:0px;float:none;vertical-align:baseline;min-height:auto;white-space:pre;">##特質first_trait<code class="php plain" style="margin:3px auto 0px;padding:0px 0px 0px 5px;background:rgb(255,255,255);border-left:3px solid rgb(108,226,108);font-size:14px;clear:both;border-top:0px;border-right:0px;border-bottom:0px;float:none;vertical-align:baseline;font-family:Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;min-height:auto;color:#000000;">
{ #
function #first_method() { echo #"方法" #; }
}
特質 secondary_trait { #function #second_method() { echo #"方法" ; }
}
first_class {
## // 現在使用多個特質
##use #first_trait, secondary_trait;
#}
##$obj = new #first_class();
# // 有效->first_method();
#$obj ##->second_method ( ); //列印:方法
|