{"id":2808,"date":"2023-09-17T20:46:59","date_gmt":"2023-09-17T18:46:59","guid":{"rendered":"https:\/\/digitalia.culturanuova.net\/blog\/?p=2808"},"modified":"2023-09-17T20:48:21","modified_gmt":"2023-09-17T18:48:21","slug":"set-a-variable-php-from-another-webpage","status":"publish","type":"post","link":"https:\/\/digitalia.culturanuova.net\/blog\/?p=2808","title":{"rendered":"set a variable php from another webpage"},"content":{"rendered":"\n<p>This can be useful to build a multilingual website. The code is very simple. Suppose to have a variable <code><strong>lang<\/strong><\/code> of the <code><strong>body<\/strong><\/code> of you pages. Something like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;body lang=\"&lt;?php if(empty($lang)) {echo \"it\";} else {echo\"$lang\";} ?&gt;\"&gt;\n <\/code><\/pre>\n\n\n\n<p>And suppose that you want set the lang (language) of the target page from a link in a starting page.<\/p>\n\n\n\n<p>You can use a code like the following<\/p>\n\n\n\n<p>In the starting (aaa.1.php): <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;p&gt;&lt;a href=\"aaa.2.php?setlang=en\"&gt;eng&lt;\/a&gt;&lt;br \/&gt;&lt;a href=\"aaa.2.php?setlang=it\"&gt;ita&lt;\/a&gt;&lt;br \/&gt;&lt;a href=\"aaa.2.php?setlang=es\"&gt;esp&lt;\/a&gt;&lt;\/p&gt;<\/code><\/pre>\n\n\n\n<p>In the target page (aaa.2.php):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n$lang = $_GET&#91;'setlang'];\n?&gt;\n&lt;html&gt;\n &lt;body lang=\"&lt;?php if(empty($lang)) {echo \"it\";} else {echo\"$lang\";} ?&gt;\"&gt;\n&lt;p&gt;your content here&lt;\/p&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This can be useful to build a multilingual website. The code is very simple. Suppose to have a variable lang of the body of you pages. Something like this: And suppose that you want set the lang (language) of the target page from a link in a starting page. You can use a code like &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/digitalia.culturanuova.net\/blog\/?p=2808\" class=\"more-link\">Leggi tutto<span class=\"screen-reader-text\"> &#8220;set a variable php from another webpage&#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":[751,566],"tags":[],"class_list":["post-2808","post","type-post","status-publish","format-standard","hentry","category-php","category-webmaster"],"_links":{"self":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2808","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=2808"}],"version-history":[{"count":2,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2808\/revisions"}],"predecessor-version":[{"id":2810,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2808\/revisions\/2810"}],"wp:attachment":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2808"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2808"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2808"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}