Editing PHP code
- php code can be edited in the html view of the editor.
- php code is embedded into a post in the same way as you are used to: a php block begins with ''. The short open tag, i.e. '
- One restriction is, that you are not allowed to use the ending delimeter ('?>') somewhere inside a string in your php code block. If you do so, this ending delimeter will be matched and your code will inevitably break apart. So don’t write e.g.:
some text
<?php $test = "hello ?>" ?>
more text
- Writing '$test = "hello ?>"' instead will not lead to any problems.
- Php code is not executed in the global scope. If you need to gain access to variables in the global scope you need to "import" them first with 'global $var1, $var2;'.
- This plugin does not evaluate every single code snippet, but the content of the post as a whole. So the following lines won’t result in errors:
<?php if ($test==true) { ?>
The test was successful.
<?php } else { ?>
The test failed.
<?php } ?>
- When switching between html and visual view the php code is not altered in any case. All html tags, whitespaces etc. in your code are preserved.