{"id":8521,"date":"2022-11-18T20:39:11","date_gmt":"2022-11-18T18:39:11","guid":{"rendered":"https:\/\/www.main-vision.com\/richard\/blog\/?p=8521"},"modified":"2022-11-18T20:39:32","modified_gmt":"2022-11-18T18:39:32","slug":"a-shift-to-php","status":"publish","type":"post","link":"https:\/\/www.main-vision.com\/richard\/blog\/a-shift-to-php\/","title":{"rendered":"A Shift to PHP"},"content":{"rendered":"<span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\"> 2<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span>\n<p>PHP has been around for decades but I learned of a way to experiment with it easily recently so that is why I am playing with it now. The main page is php as is my first &#8220;blog&#8221; although it was part of a column for the student newspaper, that I converted to an electronic format and published frequently. <\/p>\n\n\n\n<p>I tried to keep <a href=\"https:\/\/main-vision.com\/richard\/surfing.php\" data-type=\"URL\" data-id=\"https:\/\/main-vision.com\/richard\/surfing.php\">Surfing the World Wide Waves<\/a> looking as it had back in the day. The aim is to practice with PHP and get some things to become automatic. I include one php file with the data, and a second for the footer. I use a loop to populate each blog post.<\/p>\n\n\n\n<p>It looks like this<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>include data_file.php<\/li>\n\n\n\n<li>echo header etc. <\/li>\n\n\n\n<li>article title, content etc<\/li>\n\n\n\n<li>include footer<\/li>\n<\/ul>\n\n\n\n<p>The format is simple and I could have made everything a for each loop so that each page is generated automatically but for the sake of learning and persistance I updated each page individually. <\/p>\n\n\n\n<p>Aside from learning how to use PHP it was also an opportunity to practice using VIM. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/i0.wp.com\/www.main-vision.com\/richard\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-2022-11-18-at-19.30.14.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"276\" height=\"258\" src=\"https:\/\/i0.wp.com\/www.main-vision.com\/richard\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-2022-11-18-at-19.30.14.png?resize=276%2C258&#038;ssl=1\" alt=\"\" class=\"wp-image-8523\" srcset=\"https:\/\/i0.wp.com\/www.main-vision.com\/richard\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-2022-11-18-at-19.30.14.png?w=276&amp;ssl=1 276w, https:\/\/i0.wp.com\/www.main-vision.com\/richard\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-2022-11-18-at-19.30.14.png?resize=150%2C140&amp;ssl=1 150w\" sizes=\"auto, (max-width: 276px) 100vw, 276px\" \/><\/a><figcaption class=\"wp-element-caption\">List of PHP files accessed with vim. <\/figcaption><\/figure>\n\n\n\n<p>VIM is great for this process because you type vim name of file and you edit the little lines. I used shift V to use visual edit. I bulk deleted the old code I wanted to replace with the include footer line. It&#8217;s a repetitive task but that&#8217;s good for learning, and for a skill to practice and become habit. <\/p>\n\n\n\n<p>Now that this repetitive task has been done I have more flexibility to edit the footer without having to edit every other individual file. I would have tried with the header element but I need to think about how to do this without losing meta data etc. It should be added to the data file and I could access it as a variable in a different part of the page. <\/p>\n\n\n\n<p>With time I will fine tune all of these ideas and it will be reusable for future projects. <\/p>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\"> 2<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span>PHP has been around for decades but I learned of a way to experiment with it easily recently so that is why I am playing with it now. The main page is php as is my first &#8220;blog&#8221; although it was part of a column for the student newspaper, that I converted to an electronic [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[8],"tags":[4033,4996],"class_list":["post-8521","post","type-post","status-publish","format-standard","hentry","category-website-news","tag-php","tag-website-update"],"jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/posts\/8521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/comments?post=8521"}],"version-history":[{"count":2,"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/posts\/8521\/revisions"}],"predecessor-version":[{"id":8525,"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/posts\/8521\/revisions\/8525"}],"wp:attachment":[{"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/media?parent=8521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/categories?post=8521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/tags?post=8521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}