Using PHP class, When I try to use a variable for $oFCKeditor->Value
I get the following:
Warning: htmlspecialchars() expects parameter 1 to be string, resource given in /fckeditor/fckeditor_php4.php on line 58
I am trying to read a htm file with only the text "Test" saved in the file, and then passing it to $oFCKeditor->Value
$oFCKeditor->Value = $fp ;
I get the following:
Warning: htmlspecialchars() expects parameter 1 to be string, resource given in /fckeditor/fckeditor_php4.php on line 58
I am trying to read a htm file with only the text "Test" saved in the file, and then passing it to $oFCKeditor->Value
$fp = fopen("../body/test.htm", "r") ; flock($fp, 1); $oFCKeditor = new FCKeditor('FCKeditor1') ; $oFCKeditor->BasePath = '/update/fckeditor/' ; $oFCKeditor->Value = $fp ; $oFCKeditor->Create() ; flock($fp, 3); fclose($fp);
Re: Using a variable for $oFCKeditor->Value
Re: Using a variable for $oFCKeditor->Value
For those fairly new to PHP like me, here's what's happening in the code
$get_file = file("../body/test.htm");
reads the entire file storing each line of the file as a separate element of an array "$get_file".
If you pass the "$get_file" variable to the editor,
$oFCKeditor->Value = ' '.$get_file ;
only the last line, or element, of the file is passed.
To pass the whole file as a string, the array needs to be imploded by removing the "new line" character.
$edit = implode( "\n", $get_file ) ;
"\n" tells the implode command to remove the "new line" character, which will "implode" all the separate elements of the array into
one single string which is stored in the variable "$edit"
$oFCKeditor->Value = ''.$edit ;
The empty single quotes, ' ', are left so the, fckeditor_php4.php, does not return the above warning in my first post.
The , .$edit, appends the string stored in this variable to the end of the empty string, ' ', passing the whole file to the editor.
Just maybe this post will alleviate a headache or two...