{"id":29105,"date":"2018-12-17T14:11:18","date_gmt":"2018-12-17T12:11:18","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=29105"},"modified":"2018-12-17T14:11:26","modified_gmt":"2018-12-17T12:11:26","slug":"the-best-way-to-get-the-full-php-version-string","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2018\/12\/17\/the-best-way-to-get-the-full-php-version-string\/","title":{"rendered":"The best way to get the full PHP version string"},"content":{"rendered":"<!-- google_ad_section_start -->\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.jeffgeerling.com\/\">Jeff Geerling<\/a> shares <a href=\"https:\/\/www.jeffgeerling.com\/blog\/2018\/best-way-get-full-php-version-string\">the best way to get the full PHP version string<\/a>.\u00a0 I&#8217;d think that &#8220;<em>php &#8211;version<\/em>&#8221; externally or &#8220;<em>echo PHP_VERSION<\/em>&#8221; internally would do the job.\u00a0 However, that&#8217;s not exactly right, as there are a number of inconsistencies on different platforms.\u00a0 The best option seems to be the combination of the <em>PHP_MAJOR_VERSION<\/em>, <em>PHP_MINOR_VERSION<\/em>, and <em>PHP_RELEASE_VERSION<\/em> constants.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ php -r 'echo join(\".\",&#x5B;PHP_MAJOR_VERSION,PHP_MINOR_VERSION,PHP_RELEASE_VERSION]);'\n7.2.12\n<\/pre><\/div><!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>Jeff Geerling shares the best way to get the full PHP version string.\u00a0 I&#8217;d think that &#8220;php &#8211;version&#8221; externally or &#8220;echo PHP_VERSION&#8221; internally would do the job.\u00a0 However, that&#8217;s not exactly right, as there are a number of inconsistencies on different platforms.\u00a0 The best option seems to be the combination of the PHP_MAJOR_VERSION, PHP_MINOR_VERSION, and &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2018\/12\/17\/the-best-way-to-get-the-full-php-version-string\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">The best way to get the full PHP version string<\/span><\/a><\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"The best way to get the full PHP version string #WebDev #hosting #PHP","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},"_links_to":"","_links_to_target":""},"categories":[1,18,133,62,1334],"tags":[3069,38,1330,2289],"keyring_services":[],"class_list":["post-29105","post","type-post","status-publish","format-standard","hentry","category-general","category-programming","category-sysadmin","category-technology","category-web-work","tag-best-practices","tag-php","tag-web-development","tag-web-hosting"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":23603,"url":"https:\/\/mamchenkov.net\/wordpress\/2015\/02\/25\/php-tags-once-and-for-all-yet-again\/","url_meta":{"origin":29105,"position":0},"title":"PHP tags &#8211; once and for all. Yet again.","author":"Leonid Mamchenkov","date":"February 25, 2015","format":false,"excerpt":"For those of us who have been using PHP since the early version 3 days and such, here is a modern day refresher for PHP tags: If a file is pure PHP code, it is preferable to omit the PHP closing tag at the end of the file. This prevents\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27408,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/03\/11\/validating-json-against-schema-in-php\/","url_meta":{"origin":29105,"position":1},"title":"Validating JSON against schema in PHP","author":"Leonid Mamchenkov","date":"March 11, 2017","format":false,"excerpt":"GitHub was rather slow yesterday, which affected the speed of installing composer dependencies (since most of them are hosted on GitHub anyway). \u00a0Staring at a slowly scrolling list of installed dependencies, I noticed something interesting. Of course, I've heard of the seld\/jsonlint before. \u00a0It's a port of zaach\/jsonlint JavaScript tool\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27340,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/02\/12\/php-overwrite-of-built-in-constants-true-is-false\/","url_meta":{"origin":29105,"position":2},"title":"PHP overwrite of built-in constants (true is false)","author":"Leonid Mamchenkov","date":"February 12, 2017","format":false,"excerpt":"Here is a scary thing I picked up on Reddit PHP: Until PHP 5.6 this was throwing a parse error, but from then on - it's just fine. \u00a0Scary, right? The comments on the Reddit thread are quite helpful. \u00a0Technically, this is not overwriting (shadowing?) since the original constant is\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27279,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/01\/30\/sharing-constants-between-php-classes\/","url_meta":{"origin":29105,"position":3},"title":"Sharing constants between PHP classes","author":"Leonid Mamchenkov","date":"January 30, 2017","format":false,"excerpt":"When writing larger applications, it is often useful to have some constants defined, which can then be shared between different parts of the application. \u00a0There are several ways to do this, and there is no real rocket science here. However, the question is: what's the best way to do so?\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":12138,"url":"https:\/\/mamchenkov.net\/wordpress\/2010\/02\/12\/php-variables-strings-and-curly-braces\/","url_meta":{"origin":29105,"position":4},"title":"PHP variables, strings, and curly braces","author":"Leonid Mamchenkov","date":"February 12, 2010","format":false,"excerpt":"For the last couple of days we had a number arguments at work about what is the best way to surround a complex PHP variable inside a double-quoted string. \u00a0More specifically, should the sigil ($, dollar sign) be on the inside of the braces or on the outside. \u00a0Consider an\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26949,"url":"https:\/\/mamchenkov.net\/wordpress\/2016\/11\/24\/quick-way-to-create-a-php-stdclass\/","url_meta":{"origin":29105,"position":5},"title":"Quick way to create a PHP stdClass","author":"Leonid Mamchenkov","date":"November 24, 2016","format":false,"excerpt":"Simon Holywell shows how to quickly create the stdClass in PHP and populate it with properties and values, by casting an array to an object: A couple of things to keep in mind here are: In PHP, an associative array key have multiple same keys. \u00a0If you cast such an\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/29105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=29105"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/29105\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=29105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=29105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=29105"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=29105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}