{"id":191,"date":"2014-06-05T10:09:09","date_gmt":"2014-06-05T18:09:09","guid":{"rendered":"http:\/\/www.tech.dimprash.com\/?p=191"},"modified":"2014-09-26T17:32:19","modified_gmt":"2014-09-27T01:32:19","slug":"what-are-magic-quotes-magic-methods-short-tags-in-php","status":"publish","type":"post","link":"http:\/\/www.tech.dimprash.com\/?p=191","title":{"rendered":"What are magic methods, magic quotes, short tags in php?"},"content":{"rendered":"<p><strong>Magic Methods:<\/strong> <\/p>\n<p>PHP functions that start with a double underscore \u2013 a \u201c__\u201d \u2013 are called magic functions (and\/or methods) in PHP. They are functions that are always defined inside classes, and are not stand-alone (outside of classes) functions. The magic functions available in PHP are: __construct(), __destruct(), __call(), __callStatic(), __get(), __set(), __isset(), __unset(), __sleep(), __wakeup(), __toString(), __invoke(), __set_state(), __clone(), and __autoload().<\/p>\n<p>Why are they called Magic Methods?<br \/>\nThe definition of a magic function is provided by the programmer \u2013 meaning you, as the programmer, will actually write the definition. This is important to remember \u2013 PHP does not provide the definitions of the magic functions \u2013 the programmer must actually write the code that defines what the magic function will do. But, magic functions will never directly be called by the programmer \u2013 actually, PHP will call the function \u2018behind the scenes\u2019. This is why they are called \u2018magic\u2019 functions \u2013 because they are never directly called, and they allow the programmer to do some pretty powerful things.<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"bP2HqqYZoz\"><p><a href=\"https:\/\/www.programmerinterview.com\/php-questions\/php-what-are-magic-functions\/\">PHP: What are magic methods?<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;PHP: What are magic methods?&#8221; &#8212; Programmer and Software Interview Questions and Answers\" src=\"https:\/\/www.programmerinterview.com\/php-questions\/php-what-are-magic-functions\/embed\/#?secret=bP2HqqYZoz\" data-secret=\"bP2HqqYZoz\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p><strong>Magic Quotes:<\/strong><br \/>\nMagic Quotes is a process that automagically escapes incoming data to the PHP script. It&#8217;s preferred to code with magic quotes off and to instead escape the data at runtime, as needed.<\/p>\n<p>This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.<\/p>\n<p><strong>Short Tags:<\/strong><br \/>\n< ?= Hello World ? ><br \/>\nOutput is displayed directly to the browser. <\/p>\n<p>&#8211; PHP also allows for short open tags <? and ?> which are discouraged because they are only available if enabled with short_open_tag php.ini configuration file directive<br \/>\n&#8211; Can have problems with portability if the server does not allow short tags<br \/>\n&#8211; Can interfere with XML documents. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Magic Methods: PHP functions that start with a double underscore \u2013 a \u201c__\u201d \u2013 are called magic functions (and\/or methods) in PHP. They are functions that are always defined inside classes, and are not stand-alone (outside of classes) functions. The magic functions available in PHP are: __construct(), __destruct(), __call(), __callStatic(), __get(), __set(), __isset(), __unset(), __sleep(), &hellip; <a href=\"http:\/\/www.tech.dimprash.com\/?p=191\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">What are magic methods, magic quotes, short tags in php?<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,10],"tags":[],"class_list":["post-191","post","type-post","status-publish","format-standard","hentry","category-uncategorized","category-php"],"_links":{"self":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts\/191","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=191"}],"version-history":[{"count":7,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts\/191\/revisions"}],"predecessor-version":[{"id":432,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts\/191\/revisions\/432"}],"wp:attachment":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=191"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}