{"id":11107041,"date":"2019-01-19T06:39:40","date_gmt":"2019-01-19T06:39:40","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/why-does-my-code-crashes-wordpress\/"},"modified":"2019-01-19T07:38:41","modified_gmt":"2019-01-19T07:38:41","slug":"why-does-my-code-crashes-wordpress","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/why-does-my-code-crashes-wordpress\/","title":{"rendered":"Why does my code crashes WordPress?"},"content":{"rendered":"<p>WP: 5.0.2<br \/>\nPHP: recently updated 5.6 &gt; 7.2<\/p>\n<p>My code suddenly creates problems. When I save the page wordpress crashes und I get a text only page with zero style elements &#8211; like you open a text page in your browser. <\/p>\n<p>One the frontend the page renders &#8211; but the side panel is missing.<\/p>\n<p>I found the backend troublemaker, but I wonder why.<\/p>\n<p>Bad code:<\/p>\n<pre><code>&lt;?php\nif(isset($_POST[&#039;imodel&#039;])){ $mod = $_POST[&#039;imodel&#039;]; } ELSE {$mod = &#039;iPhone Xs&#039;; $linkinsert =&#039;iphone-xs&#039;;}\nif(isset($_POST[&#039;imemory&#039;])){ $mem = $_POST[&#039;imemory&#039;]; } ELSE {$mem = &#039;64&#039;;}\n\nif(isset($_POST[&#039;curr_option&#039;])){$curr_option = $_POST[&#039;curr_option&#039;]; } ELSE {$curr_option = &#039;USD&#039;;}<\/code><\/pre>\n<p>Changed and working in backend:<\/p>\n<pre><code>&lt;?php\nif(!empty($_POST[&#039;imodel&#039;]) || !empty($_POST[&#039;imemory&#039;])){\n    $mod = &#039;iPhone Xs&#039;; $linkinsert =&#039;iphone-xs&#039;; $mem = &#039;64&#039;;\n}\n\nif(isset($_POST[&#039;curr_option&#039;])){$curr_option = $_POST[&#039;curr_option&#039;]; } ELSE {$curr_option = &#039;USD&#039;;}<\/code><\/pre>\n<p>However, in the frontend the side-panel still disappears on reload.<\/p>\n<p>Need to add that the <em>bad code<\/em> did run in PHP 5.6 (or previous WP version) without problem.<\/p>\n","protected":false},"template":"","class_list":["post-11107041","topic","type-topic","status-publish","hentry","topic-tag-isset"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11107041","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11107041\/revisions"}],"predecessor-version":[{"id":11107121,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11107041\/revisions\/11107121"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=11107041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}