{"id":7547,"date":"2019-10-31T12:09:44","date_gmt":"2019-10-31T12:09:44","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=7547"},"modified":"2022-05-08T12:07:22","modified_gmt":"2022-05-08T12:07:22","slug":"php-local-variable","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/php-local-variable\/","title":{"rendered":"How to declare a local &#038; global variable in PHP?"},"content":{"rendered":"\n<p class=\"has-medium-font-size\"><strong>Local Variable:-<\/strong><\/p>\n\n\n\n<p>Local Variables mean local is declared inside a function. Its value applies in any function. When local variable value modified in one function then changes not apply in other function changes apply in particular function. <\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/Bitbuckettraining\/3235e1987b3dd70c6beb2676df0bfe04.js\"><\/script>\n\n\n\n<p class=\"has-medium-font-size\"><strong>PHP- Global Variable:-<\/strong><\/p>\n\n\n\n<p>Global Variable means that Global that declared from outside of the function. It is created before the function&#8217;s execution starts and lost when the function switch. When you want to access global function in function then add global in function then access global from inside a function.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/Bitbuckettraining\/a0ef7d8c6b51e389edad256792e2f60b.js\"><\/script>\n\n\n\n<script src=\"https:\/\/gist.github.com\/Bitbuckettraining\/d516e6378400551d3b6ecf37fa67e3c3.js\"><\/script>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_51202\"><figure class=\"wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube epyt-figure\"><div class=\"wp-block-embed__wrapper\"><iframe loading=\"lazy\"  id=\"_ytid_94508\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_51202\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><\/div><\/figure><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Local Variable:- Local Variables mean local is declared inside a function. Its value applies in any function. When local variable value modified in one function then changes not apply in other function changes apply in particular function. PHP- Global Variable:- Global Variable means that Global that declared from outside of the function. It is created&#8230;<\/p>\n","protected":false},"author":1,"featured_media":7554,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[5150],"tags":[5431,498,177,5045],"class_list":["post-7547","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-function","tag-local","tag-php","tag-variable"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/7547","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=7547"}],"version-history":[{"count":7,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/7547\/revisions"}],"predecessor-version":[{"id":25334,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/7547\/revisions\/25334"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/7554"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=7547"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=7547"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=7547"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}