我尝试在 codeigniter 项目中使用 ckeditor 制作文本编辑器。但是,每当我从我的视图中调用方法Only variables should be passed by reference
时,我总是会出现display_ckeditor
错误。
这是我的错误日志:
A PHP Error was encountered
Severity: Runtime Notice
Message: Only variables should be passed by reference
Filename: helpers/ckeditor_helper.php
Line Number: 65
Backtrace:
File: /var/www/html/webapp/webappadmin/application/helpers/ckeditor_helper.php
Line: 65
Function: _error_handler
File: /var/www/html/webapp/webappadmin/application/helpers/ckeditor_helper.php
Line: 90
Function: cke_create_instance
File: /var/www/html/webapp/webappadmin/application/views/ubahabout.php
Line: 7
Function: display_ckeditor
File: /var/www/html/webapp/webappadmin/application/controllers/Controll.php
Line: 187
Function: view
File: /var/www/html/webapp/webappadmin/index.php
Line: 292
Function: require_once
这是我的控制器加载视图:
public function ubahabout($id,$tab,$lang){
//Ckeditor's configuration
$data['ckeditor'] = array(
//ID of the textarea that will be replaced
'id' => 'content',
'path' => 'js/ckeditor',
//Optionnal values
'config' => array(
'toolbar' => "Full", //Using the Full toolbar
'width' => "550px", //Setting a custom width
'height' => '100px', //Setting a custom height
),
//Replacing styles from the "Styles tool"
'styles' => array(
//Creating a new style named "style 1"
'style 1' => array (
'name' => 'Blue Title',
'element' => 'h2',
'styles' => array(
'color' => 'Blue',
'font-weight' => 'bold'
)
),
//Creating a new style named "style 2"
'style 2' => array (
'name' => 'Red Title',
'element' => 'h2',
'styles' => array(
'color' => 'Red',
'font-weight' => 'bold',
'text-decoration' => 'underline'
)
)
)
);
$data['myid']=$id;
$data['mylang']=$lang;
$data['mytab']=$tab;
$this->load->view('ubahabout',$data); // <---- ERROR GOES HERE
}
这是我的观点(ubahabout.php):
<div class="main-container">
<?php
$content = $this->contentmodel->load_main_content_by_id($myid);
?>
<textarea name="content" id="content" ><p>Example data</p></textarea>
<?php
echo display_ckeditor($ckeditor); // <---- ERROR GOES HERE ?>
</div>
错误指出 ckeditor_helper.php 内的第90行和第65行,我仍然无法弄清问题是什么。这是ckeditor_helper.php中的那些行:
第90行:$return .= cke_create_instance($data);
,
第65行:if($k !== end(array_keys($data['config']))) {
请帮帮我。提前谢谢。
答案 0 :(得分:3)
我也有这个问题, 问题不是你的脚本,而是文件'helpers / ckeditor_helper.php' 如错误消息所示。
线65,108,116各自具有相同的问题。 而不是在'end()'中运行array_keys函数, 首先分配给变量,然后在函数中使用变量。
<强>助手/ ckeditor_helper.php 强>
64. $endkeys = (array_keys($data['config'])); 65. if($k !== end($endkeys)) {
107. $endkeys2 = array_keys($v['styles']); 108. if($k2 !== end($endkeys2)) {
115. $endkeys3 = array_keys($data['styles']); 116. if($k !== end($endkeys3)) {
那应该解决这个问题。
答案 1 :(得分:0)
我认为
的第一个论点$this->load->view('ubahabout',$data);
是一个参考,只需尝试:
$a = 'ubahabout';
$this->load->view($a, $data);
但不确定,您还应该显示$this->load->view
答案 2 :(得分:0)
在system / helper修改ckeditor_helper.php
- $ endkeys =(array_keys($ data ['config']));
if($ k!== end($ endkeys)){
$ endkeys2 = array_keys($ v ['styles']);
if($ k2!== end($ endkeys2)){
$ endkeys3 = array_keys($ data ['styles']);
- if($ k!== end($ endkeys3)){
醇>151 $ endkeys = array_values($ key); 152 if($ string!== 结束($ endkeys))$ return。=“,”;
160 $ endkeys = array_values($ data); 161 if($ key!= end($ endkeys)) $ return。=“,”;