{"id":111,"date":"2021-03-08T00:21:58","date_gmt":"2021-03-08T00:21:58","guid":{"rendered":"https:\/\/phptutorial.net\/?page_id=111"},"modified":"2021-06-27T05:06:35","modified_gmt":"2021-06-27T05:06:35","slug":"php-autoloading-class-files","status":"publish","type":"page","link":"https:\/\/www.phptutorial.net\/php-oop\/php-autoloading-class-files\/","title":{"rendered":"PHP Autoloading Class Files"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to organize your class files and load them automatically using PHP&nbsp; <code>spl_autoload_register()<\/code> function.<\/p>\n\n\n\n<p>It is good practice to keep each <a href=\"https:\/\/phptutorial.net\/php-oop\/php-objects\/\">PHP class<\/a> in a separate file. Also, the name of the class should be the same as the file name. For example, the <code>Contact.php<\/code> file should contain the <code>Contact<\/code> class.<\/p>\n\n\n\n<p>Before using a class, you need to:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>First, define the class in a file.<\/li><li>Second, load it using the <code>require<\/code>, <code>require_once<\/code>, <code>include<\/code>, or <code>include_once<\/code> statement. <\/li><\/ul>\n\n\n\n<p>Suppose that you have the following project directory structure:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\">.\n\u251c\u2500\u2500 <span class=\"hljs-selector-tag\">index<\/span><span class=\"hljs-selector-class\">.php<\/span>\n\u2514\u2500\u2500 <span class=\"hljs-selector-tag\">models<\/span>\n    \u2514\u2500\u2500 <span class=\"hljs-selector-tag\">Contact<\/span><span class=\"hljs-selector-class\">.php<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>models<\/code> directory has the <code>Contact.php<\/code> file that contains the following <code>Contact<\/code> class:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Contact<\/span>\n<\/span>{\n\t<span class=\"hljs-keyword\">private<\/span> $email;\n\n\t<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">__construct<\/span><span class=\"hljs-params\">(string $email)<\/span>\n\t<\/span>{\n\t\t<span class=\"hljs-keyword\">$this<\/span>-&gt;email = $email;\n\t}\n\n\t<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">getEmail<\/span><span class=\"hljs-params\">()<\/span>\n\t<\/span>{\n\t\t<span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-keyword\">$this<\/span>-&gt;email;\n\t}\n}\n<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>From the index.php file, you can load the <code>models\/Contact.php<\/code> file and use the <code>Contact<\/code> class as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-keyword\">require_once<\/span> <span class=\"hljs-string\">'models\/Contact.php'<\/span>;\n$contact = <span class=\"hljs-keyword\">new<\/span> Contact(<span class=\"hljs-string\">'john.doe@example.com'<\/span>);\n<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>This solution works fine if you have a small number of files. When the number of files grows, the <code>require_once<\/code> statement doesn&#8217;t scale well.<\/p>\n\n\n\n<p>To resolve it, you can define a function that takes a class name as an argument and includes the file that contains the class definition. For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">load_model<\/span><span class=\"hljs-params\">($class_name)<\/span>\n<\/span>{\n\t$path_to_file = <span class=\"hljs-string\">'models\/'<\/span> . $class_name . <span class=\"hljs-string\">'.php'<\/span>;\n\n\t<span class=\"hljs-keyword\">if<\/span> (file_exists($path_to_file)) {\n\t\t<span class=\"hljs-keyword\">require<\/span> $path_to_file;\n\t}\n}<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>load_class()<\/code> function looks for the class file in the <code>models<\/code> directory and includes it if the file exists. And you can place the <code>load_model()<\/code> function in the <code>functions.php<\/code> file:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">.\n\u251c\u2500\u2500 functions.php\n\u251c\u2500\u2500 index.php\n\u2514\u2500\u2500 models\n    \u2514\u2500\u2500 Contact.php<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To use the <code>load_model()<\/code> function in the <code>index.php<\/code> file, you can include the <code>functions.php<\/code> file and call the <code>load_model()<\/code> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-keyword\">require_once<\/span> <span class=\"hljs-string\">'functions.php'<\/span>;\n\nload_model(<span class=\"hljs-string\">'Person'<\/span>);\n\n$person = <span class=\"hljs-keyword\">new<\/span> Person();<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='autoloader-with-spl_autoload_register-function'>Autoloader with spl_autoload_register() function <a href=\"#autoloader-with-spl_autoload_register-function\" class=\"anchor\" id=\"autoloader-with-spl_autoload_register-function\" title=\"Anchor for Autoloader with spl_autoload_register() function\">#<\/a><\/h2>\n\n\n\n<p>PHP 5.1.2 introduced the <code>spl_autoload_register()<\/code> function that automatically loads a class file whenever you use a class that has not been loaded yet.<\/p>\n\n\n\n<p class=\"note\">PHP 7.2.0 deprecated the <code>__autoload()<\/code> magic function and recommended to use the <code>spl_autoload_register()<\/code> function instead.<\/p>\n\n\n\n<p>When you use a class that has not been loaded, PHP will automatically look for <code>spl_autoload_register()<\/code> function call.<\/p>\n\n\n\n<p>The <code>spl_autoload_register()<\/code> function accepts a callback function and calls it when you attempt to create use a class that has not been loaded. <\/p>\n\n\n\n<p>To use the <code>spl_autoload_register()<\/code> function, you can pass the <code>load_model<\/code> function to it as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">load_model<\/span><span class=\"hljs-params\">($class_name)<\/span>\n<\/span>{\n\t$path_to_file = <span class=\"hljs-string\">'models\/'<\/span> . $class_name . <span class=\"hljs-string\">'.php'<\/span>;\n\n\t<span class=\"hljs-keyword\">if<\/span> (file_exists($path_to_file)) {\n\t\t<span class=\"hljs-keyword\">require<\/span> $path_to_file;\n\t}\n}\n\n\nspl_autoload_register(<span class=\"hljs-string\">'load_model'<\/span>);\n<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>And from the <code>index.php<\/code> file, you don&#8217;t need to call the <code>load_model()<\/code> function whenever you use a class in the <code>models<\/code> directory:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-keyword\">require<\/span> <span class=\"hljs-string\">'functions.php'<\/span>;\n\n$contact = <span class=\"hljs-keyword\">new<\/span> Contact(<span class=\"hljs-string\">'john.doe@example.com'<\/span>);<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='multiple-autoload-functions'>Multiple autoload functions <a href=\"#multiple-autoload-functions\" class=\"anchor\" id=\"multiple-autoload-functions\" title=\"Anchor for Multiple autoload functions\">#<\/a><\/h2>\n\n\n\n<p>The <code>spl_autoload_register()<\/code> function allows you to use multiple autoloading functions. The <code>spl_autoload_register()<\/code> function will create a queue of autoloading functions and runs through each of them in the order that they are defined.<\/p>\n\n\n\n<p>For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\nspl_autoload_register(<span class=\"hljs-string\">'autoloader1'<\/span>);\nspl_autoload_register(<span class=\"hljs-string\">'autoloader2'<\/span>);\nspl_autoload_register(<span class=\"hljs-string\">'autoloader3'<\/span>);<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this example, PHP will run the <code>autoloader1<\/code>, <code>autoload2<\/code>, and <code>autoloader3<\/code> sequentially to load the class files.<\/p>\n\n\n\n<p>To demonstrate this, let&#8217;s create a new directory called <code>services<\/code> that stores service class files and create an <code>Email.php<\/code> file inside the <code>services<\/code> directory. <\/p>\n\n\n\n<p>The following defines the <code>Email<\/code> class:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Email<\/span>\n<\/span>{\n\t<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">static<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">send<\/span><span class=\"hljs-params\">($contact)<\/span>\n\t<\/span>{\n\t\t<span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-string\">'Sending an email to '<\/span> . $contact-&gt;getEmail();\n\t}\n}<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The project directory now looks like this:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">.\n\u251c\u2500\u2500 functions.php\n\u251c\u2500\u2500 index.php\n\u251c\u2500\u2500 models\n\u2502   \u2514\u2500\u2500 Contact.php\n\u2514\u2500\u2500 services\n    \u2514\u2500\u2500 Email.php<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In the <code>functions.php<\/code> file, you can define a function that loads the classes from the <code>services<\/code> directory and pass the function name to the <code>spl_autoload_register()<\/code> function like this:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">load_model<\/span><span class=\"hljs-params\">($class_name)<\/span>\n<\/span>{\n\t$path_to_file = <span class=\"hljs-string\">'models\/'<\/span> . $class_name . <span class=\"hljs-string\">'.php'<\/span>;\n\n\t<span class=\"hljs-keyword\">if<\/span> (file_exists($path_to_file)) {\n\t\t<span class=\"hljs-keyword\">require<\/span> $path_to_file;\n\t}\n}\n\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">load_service<\/span><span class=\"hljs-params\">($service_name)<\/span>\n<\/span>{\n\t$path_to_file = <span class=\"hljs-string\">'services\/'<\/span> . $service_name . <span class=\"hljs-string\">'.php'<\/span>;\n\n\t<span class=\"hljs-keyword\">if<\/span> (file_exists($path_to_file)) {\n\t\t<span class=\"hljs-keyword\">require<\/span> $path_to_file;\n\t}\n}\n\nspl_autoload_register(<span class=\"hljs-string\">'load_model'<\/span>);\nspl_autoload_register(<span class=\"hljs-string\">'load_service'<\/span>);<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>From the <code>index.php<\/code>, you can use the <code>Contact<\/code> and <code>Email<\/code> classes as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-keyword\">require<\/span> <span class=\"hljs-string\">'functions.php'<\/span>;\n\n$contact = <span class=\"hljs-keyword\">new<\/span> Contact(<span class=\"hljs-string\">'john.doe@example.com'<\/span>);\n\n<span class=\"hljs-keyword\">echo<\/span> Email::send($contact);<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">Sending an email to john.doe@example.com<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Like classes, you can also load the <a href=\"https:\/\/phptutorial.net\/php-tutorial\/php-interface\/\">interfaces<\/a> and <a href=\"https:\/\/phptutorial.net\/php-oop\/php-traits\/\">traits<\/a> using same autoloading function.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>An autoloading function loads a class, an interface, or a trait from a PHP file.<\/li><li>Use the <code>spl_autoload_register()<\/code> function to autoload the classes, interfaces, and traits.<\/li><\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Did you find this tutorial useful?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"111\"\n\t\t\t\tdata-post-url=\"https:\/\/www.phptutorial.net\/php-oop\/php-autoloading-class-files\/\"\n\t\t\t\tdata-post-title=\"PHP Autoloading Class Files\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"111\"\n\t\t\t\tdata-post-url=\"https:\/\/www.phptutorial.net\/php-oop\/php-autoloading-class-files\/\"\n\t\t\t\tdata-post-title=\"PHP Autoloading Class Files\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows you how to load class files automatically by using the spl_autoload_register function.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1753,"menu_order":29,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-111","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/pages\/111","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/comments?post=111"}],"version-history":[{"count":5,"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/pages\/111\/revisions"}],"predecessor-version":[{"id":2048,"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/pages\/111\/revisions\/2048"}],"up":[{"embeddable":true,"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/pages\/1753"}],"wp:attachment":[{"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/media?parent=111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}