{"id":6611,"date":"2014-04-20T13:46:05","date_gmt":"2014-04-20T13:46:05","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/20\/why-is-this-require-causing-a-fatal-error-collection-of-common-programming-errors\/"},"modified":"2014-04-20T13:46:05","modified_gmt":"2014-04-20T13:46:05","slug":"why-is-this-require-causing-a-fatal-error-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/20\/why-is-this-require-causing-a-fatal-error-collection-of-common-programming-errors\/","title":{"rendered":"Why is this &ldquo;require&rdquo; causing a fatal error?-Collection of common programming errors"},"content":{"rendered":"<p>I inherited a file called promo.php. It begins with the lines:<\/p>\n<pre><code>define('ROOT', dirname(dirname(dirname(__FILE__))));\nrequire_once ROOT. '\/app\/config\/database.php';\nrequire_once ROOT. '\/app\/config\/constants.php';\n<\/code><\/pre>\n<p>And works well enough. For testing purposes though I created a file called promo-2.php in the same folder, beginning with the same lines. In this case, the file dies with a fatal error at at the first require.<\/p>\n<p>As far as I can make out, the required file is not being found. But how can this be the case when promo-2.php is in the some directory as promo.php? Surely ROOT will be the same in both places? Could there be some kind of permissions issue that I haven&#8217;t thought of? All suggestions gratefully received!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I inherited a file called promo.php. It begins with the lines: define(&#8216;ROOT&#8217;, dirname(dirname(dirname(__FILE__)))); require_once ROOT. &#8216;\/app\/config\/database.php&#8217;; require_once ROOT. &#8216;\/app\/config\/constants.php&#8217;; And works well enough. For testing purposes though I created a file called promo-2.php in the same folder, beginning with the same lines. In this case, the file dies with a fatal error at at the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6611","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6611","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6611"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6611\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6611"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6611"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6611"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}