{"id":2991,"date":"2024-09-11T13:39:02","date_gmt":"2024-09-11T11:39:02","guid":{"rendered":"https:\/\/digitalia.culturanuova.net\/blog\/?p=2991"},"modified":"2024-10-17T12:14:47","modified_gmt":"2024-10-17T10:14:47","slug":"php-include-no-absolute-path","status":"publish","type":"post","link":"https:\/\/digitalia.culturanuova.net\/blog\/?p=2991","title":{"rendered":"php include: no absolute path"},"content":{"rendered":"\n<p>To get <code>include<\/code> command working you should avoid an absolute path: i.g. not<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;somepath\/somefile<\/code><\/pre>\n\n\n\n<p>But, i.g.:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>..\/somepath\/somefile<\/code><\/pre>\n\n\n\n<p>2) In <strong>localhost<\/strong> it would be possible this workaround:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$yourvariablepath = realpath($_SERVER&#91;\"DOCUMENT_ROOT\"] . \"\/a\/path\");<\/code><\/pre>\n\n\n\n<p>But this doesn&#8217;t work <strong>in remote<\/strong>.<\/p>\n\n\n\n<p>3) Another workaround to include a content from a file in another absolute path could be the <strong>object<\/strong> tag:<\/p>\n\n\n\n<p>&lt;object data=&#8221;your-file-even-on-another-server&#8221; \/><\/p>\n\n\n\n<p>But an object in another page is <strong>an island<\/strong>, a stranger &#8220;guest&#8221;, without any sharing with the &#8220;host&#8221; page.<\/p>\n\n\n\n<p>4) Another way (for short text) is to use <strong><a href=\"https:\/\/localhost\/web\/public_html\/digitalia\/wordpress\/?p=2592\">javascript<\/a><\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To get include command working you should avoid an absolute path: i.g. not But, i.g.: 2) In localhost it would be possible this workaround: But this doesn&#8217;t work in remote. 3) Another workaround to include a content from a file in another absolute path could be the object tag: &lt;object data=&#8221;your-file-even-on-another-server&#8221; \/> But an object &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/digitalia.culturanuova.net\/blog\/?p=2991\" class=\"more-link\">Leggi tutto<span class=\"screen-reader-text\"> &#8220;php include: no absolute path&#8221;<\/span><\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[579,751,892],"tags":[17,434],"class_list":["post-2991","post","type-post","status-publish","format-standard","hentry","category-database","category-php","category-text","tag-php","tag-php-include"],"_links":{"self":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2991"}],"version-history":[{"count":5,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2991\/revisions"}],"predecessor-version":[{"id":3010,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2991\/revisions\/3010"}],"wp:attachment":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}