我正在尝试在php论坛脚本的主页上使用带有角元素的html代码。我将这个PHP代码添加到index.template.php(应该是)。但它没有显示任何东西。
<?php
/**
* Will help you change font and colour on your forum without change templates or making CSS edits.
*/
function template_colour_picker()
{
global $txt;
echo'
<html>'
<div id="colourpicker" ng-app="myApp" ng-controller="ngPicky">
<label>$txt['font']</label>
<input type="text" ng-model="fontName" placeholder="$txt['Enter font name here']">
<label>$txt['color']</label>
<input type="text" ng-model="fontColour" placeholder="$txt['Enter colour name here']">
<label>$txt['background']</label>
<input type="text" ng-model="bgColour" placeholder="$txt'[Enter backgroundcolour name here']">
<hr>
<div class="{{fontName}} {{fontColour}} {{bgColour}}">$txt['Text']</div>
</div>
'</html>';
}
?>
解析错误:语法错误,意外错误&#39; ng&#39; (T_STRING),期待&#39;,&#39;或&#39;;&#39;在第405行的...... / themes / Silk_af_v155 / index.template.php
答案 0 :(得分:1)
您有各种concatenation错误。请注意您的单引号('
)和句点(.
)的位置。检查一下:
<?php
function template_colour_picker()
{
global $txt;
echo '
<html>
<div id="colourpicker" ng-app="myApp" ng-controller="ngPicky">
<label>'.$txt['font'].'</label>
<input type="text" ng-model="fontName" placeholder="'.$txt['Enter font name here'].'">
<label>'.$txt['color'].'</label>
<input type="text" ng-model="fontColour" placeholder="'.$txt['Enter colour name here'].'">
<label>'.$txt['background'].'</label>
<input type="text" ng-model="bgColour" placeholder="'.$txt['Enter backgroundcolour name here'].'">
<hr>
<div class="{{fontName}} {{fontColour}} {{bgColour}}">'.$txt['Text'].'</div>
</div>
</html>';
}