shane53
posted this
26 May 2021
Hi Paul.
So after 5 hours of frustration I've discovered two strange things with PHP in Nicepage/(Wordpress?). Having two issues made it difficult to figure out what was the actual cause of the problem.
Firstly, when you use the full window code editor under Nicepage/ Wordpress the first few lines of the editor get cut off from the user bar in Wordpress/ toolbar in Nicepage. To see the first few lines I would carriage return the first few lines in the editor to move the code down. In a normal editor these white spaces wouldn't have any consequences. However under Nicepage/ Wordpress this creates an error.
Secondly the way Nicepage/ Wordpress handles quotations is weird. Normally in PHP you can use quotes in the following way:
echo '<input type="text" placeholder="name">';
However this does not work. You must always escape your quotation marks:
<?php echo "<input type=\"text\">"; ?>
Strangely this also works but shouldn't:
echo '<input type=\"text\">';
I tried using XYZ PHP Code plugin in Wordpress which allows you to insert php via shortcode. It doesn't suffer from the same requirement to escape every quotation mark which leads me to believe it's a Nicepage issue.
I can code while escaping quotation marks, but the first two problems are an issue:
- First 3 lines of code in the Nicepage full screen code editor via Wordpress plugin are obstructed (see screenshot).
- Starting the code editor with carriage returns causes the PHP to error.
Thanks.
Hi Paul.
So after 5 hours of frustration I've discovered two strange things with PHP in Nicepage/(Wordpress?). Having two issues made it difficult to figure out what was the actual cause of the problem.
Firstly, when you use the full window code editor under Nicepage/ Wordpress the first few lines of the editor get cut off from the user bar in Wordpress/ toolbar in Nicepage. To see the first few lines I would carriage return the first few lines in the editor to move the code down. In a normal editor these white spaces wouldn't have any consequences. However under Nicepage/ Wordpress this creates an error.
!Screen-Shot-2021-05-26-at-3.12.23-PM.png!
Secondly the way Nicepage/ Wordpress handles quotations is weird. Normally in PHP you can use quotes in the following way:
echo '<input type="text" placeholder="name">';
However this does not work. You must always escape your quotation marks:
<?php echo "<input type=\"text\">"; ?>
Strangely this also works but shouldn't:
echo '<input type=\"text\">';
I tried using XYZ PHP Code plugin in Wordpress which allows you to insert php via shortcode. It doesn't suffer from the same requirement to escape every quotation mark which leads me to believe it's a Nicepage issue.
I can code while escaping quotation marks, but the first two problems are an issue:
1. First 3 lines of code in the Nicepage full screen code editor via Wordpress plugin are obstructed (see screenshot).
2. Starting the code editor with carriage returns causes the PHP to error.
Thanks.
Last edited 26 May 2021 by shane53