{"id":2304,"date":"2021-07-15T03:23:41","date_gmt":"2021-07-15T03:23:41","guid":{"rendered":"https:\/\/phptutorial.net\/?page_id=2304"},"modified":"2021-07-15T03:23:43","modified_gmt":"2021-07-15T03:23:43","slug":"php-anonymous-class","status":"publish","type":"page","link":"https:\/\/www.phptutorial.net\/php-oop\/php-anonymous-class\/","title":{"rendered":"PHP Anonymous Class"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn how about the PHP anonymous class and how to define anonymous classes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='introduction-to-the-php-anonymous-classes'>Introduction to the PHP anonymous classes <a href=\"#introduction-to-the-php-anonymous-classes\" class=\"anchor\" id=\"introduction-to-the-php-anonymous-classes\" title=\"Anchor for Introduction to the PHP anonymous classes\">#<\/a><\/h2>\n\n\n\n<p>So far, you have learned how to <a href=\"https:\/\/phptutorial.net\/php-oop\/php-objects\/\">define a new class<\/a> with a name. For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">MyClass<\/span> \n<\/span>{\n    <span class=\"hljs-comment\">\/\/ ...<\/span>\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>MyClass<\/code> is called a named class.<\/p>\n\n\n\n<p>An anonymous class is a class without a declared name. The following creates an object of anonymous class:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n$myObject = <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <\/span>{\n    <span class=\"hljs-comment\">\/\/ ...<\/span>\n};<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax, you place the <code>class<\/code> keyword after the <code>new<\/code> keyword. The <code>$myObject<\/code> is the instance of the anonymous class.<\/p>\n\n\n\n<p>Inside the parentheses, you can define <a href=\"https:\/\/phptutorial.net\/php-oop\/php-constructors\/\">constructor<\/a>, <a href=\"https:\/\/phptutorial.net\/php-oop\/php-destructor\/\">destructor<\/a>, properties, and methods for the anonymous class like a regular class. For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n$logger = <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <\/span>{\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">log<\/span><span class=\"hljs-params\">(string $message)<\/span>: <span class=\"hljs-title\">void<\/span>\n    <\/span>{\n        <span class=\"hljs-keyword\">echo<\/span> $message . <span class=\"hljs-string\">'&lt;br&gt;'<\/span>;\n    }\n};\n\n$logger-&gt;log(<span class=\"hljs-string\">'Hello'<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>How it works.<\/p>\n\n\n\n<p>First, create the <code>$logger<\/code> object of the anonymous class that has one method <code>log()<\/code> that displays a message with a <code><br><\/code> tag. <\/p>\n\n\n\n<p>Second, call the <code>log()<\/code> method via the <code>$logger<\/code> object.<\/p>\n\n\n\n<p>Internally, PHP generates a name for the anonymous class. To get the generated name, you can use the <code>get_class()<\/code> function. For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-keyword\">echo<\/span> get_class($logger);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/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-5\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">index.php0000025F568665BE<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>PHP manages this class name internally. Therefore, you should not rely on it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='implementing-an-interface'>Implementing an interface <a href=\"#implementing-an-interface\" class=\"anchor\" id=\"implementing-an-interface\" title=\"Anchor for Implementing an interface\">#<\/a><\/h2>\n\n\n\n<p>An anonymous can implement one or multiple <a href=\"https:\/\/phptutorial.net\/php-oop\/php-interface\/\">interfaces<\/a>. For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">interface<\/span> <span class=\"hljs-title\">Logger<\/span>\n<\/span>{\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">log<\/span><span class=\"hljs-params\">(string $message)<\/span>: <span class=\"hljs-title\">void<\/span><\/span>;\n}\n\n$logger = <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-keyword\">implements<\/span> <span class=\"hljs-title\">Logger<\/span> <\/span>{\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">log<\/span><span class=\"hljs-params\">(string $message)<\/span>: <span class=\"hljs-title\">void<\/span>\n    <\/span>{\n        <span class=\"hljs-keyword\">echo<\/span> $message . <span class=\"hljs-string\">'&lt;br&gt;'<\/span>;\n    }\n};\n\n$logger-&gt;log(<span class=\"hljs-string\">'Hello'<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this example, we define the <code>Logger<\/code> interface that has the <code>log()<\/code> method. And then, we define an anonymous class that implements the <code>Logger<\/code> interface.<\/p>\n\n\n\n<p>The <code>$logger<\/code> is the instance of the <code>Logger<\/code> interface:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-keyword\">echo<\/span> $logger <span class=\"hljs-keyword\">instanceof<\/span> Logger; <span class=\"hljs-comment\">\/\/ true<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Because an anonymous doesn&#8217;t have a declared name, you cannot use the type hint for its instance. <\/p>\n\n\n\n<p>However, when an anonymous class implements an interface, you can use the type hint via the interface. For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">interface<\/span> <span class=\"hljs-title\">Logger<\/span>\n<\/span>{\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">log<\/span><span class=\"hljs-params\">(string $message)<\/span>: <span class=\"hljs-title\">void<\/span><\/span>;\n}\n\n$logger = <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-keyword\">implements<\/span> <span class=\"hljs-title\">Logger<\/span> <\/span>{\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">log<\/span><span class=\"hljs-params\">(string $message)<\/span>: <span class=\"hljs-title\">void<\/span>\n    <\/span>{\n        <span class=\"hljs-keyword\">echo<\/span> $message . <span class=\"hljs-string\">'&lt;br&gt;'<\/span>;\n    }\n};\n\n<span class=\"hljs-comment\">\/\/ type hint<\/span>\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">save<\/span><span class=\"hljs-params\">(Logger $logger)<\/span>\n<\/span>{\n    $logger-&gt;log(<span class=\"hljs-string\">'The file was updated successfully.'<\/span>);\n}\n\nsave($logger);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='inheriting-a-class'>Inheriting a class <a href=\"#inheriting-a-class\" class=\"anchor\" id=\"inheriting-a-class\" title=\"Anchor for Inheriting a class\">#<\/a><\/h2>\n\n\n\n<p>Like a regular class, a class can <a href=\"https:\/\/phptutorial.net\/php-oop\/php-inheritance\/\">inherit from one named class<\/a>. For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">interface<\/span> <span class=\"hljs-title\">Logger<\/span>\n<\/span>{\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">log<\/span><span class=\"hljs-params\">(string $message)<\/span>: <span class=\"hljs-title\">void<\/span><\/span>;\n}\n\n<span class=\"hljs-keyword\">abstract<\/span> <span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">SimpleLogger<\/span> <span class=\"hljs-keyword\">implements<\/span> <span class=\"hljs-title\">Logger<\/span>\n<\/span>{\n    <span class=\"hljs-keyword\">protected<\/span> $newLine;\n\n    <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\">(bool $newLine)<\/span>\n    <\/span>{\n        <span class=\"hljs-keyword\">$this<\/span>-&gt;newLine = $newLine;\n    }\n\n    <span class=\"hljs-keyword\">abstract<\/span> <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">log<\/span><span class=\"hljs-params\">(string $message)<\/span>: <span class=\"hljs-title\">void<\/span><\/span>;\n}\n\n$logger = <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span>(<span class=\"hljs-title\">true<\/span>) <span class=\"hljs-keyword\">extends<\/span> <span class=\"hljs-title\">SimpleLogger<\/span> <\/span>{\n    <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\">(bool $newLine)<\/span>\n    <\/span>{\n        <span class=\"hljs-keyword\">parent<\/span>::__construct($newLine);\n    }\n\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">log<\/span><span class=\"hljs-params\">(string $message)<\/span>: <span class=\"hljs-title\">void<\/span>\n    <\/span>{\n        <span class=\"hljs-keyword\">echo<\/span> <span class=\"hljs-keyword\">$this<\/span>-&gt;newLine ? $message . PHP_EOL : $message;\n    }\n};\n\n$logger-&gt;log(<span class=\"hljs-string\">'Hello'<\/span>);\n$logger-&gt;log(<span class=\"hljs-string\">'Bye'<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>How it works.<\/p>\n\n\n\n<p>First, define an interface called Logger that has one method <code>log()<\/code>.<\/p>\n\n\n\n<p>Second, define an abstract class called <code>SimpleLogger<\/code> that implements the <code>Logger<\/code> interface.<\/p>\n\n\n\n<p>Third, define an anonymous class that extends the <code>SimpleLogger<\/code> class. We call the constructor of the <code>SimpleLogger<\/code> class in the constructor of the anonymous class.<\/p>\n\n\n\n<p>To pass an argument to the constructor, we place it in parentheses that follow the <code>class<\/code> keyword.<\/p>\n\n\n\n<p>Finally, call the <code>log()<\/code> method of the <code>$logger<\/code> object.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='when-to-use-anonymous-classes'>When to use anonymous classes <a href=\"#when-to-use-anonymous-classes\" class=\"anchor\" id=\"when-to-use-anonymous-classes\" title=\"Anchor for When to use anonymous classes\">#<\/a><\/h2>\n\n\n\n<p>Anonymous classes are helpful in some cases:<\/p>\n\n\n\n<p>First, anonymous classes make it easy to mock tests. Note that you&#8217;ll learn about unit testing with PHPUnit later.<\/p>\n\n\n\n<p>Second, anonymous classes keep their usage outside the scope where they are defined. For example, instead of doing this:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">ConsoleLogger<\/span> \n<\/span>{\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">log<\/span><span class=\"hljs-params\">($message)<\/span> \n    <\/span>{\n        <span class=\"hljs-keyword\">echo<\/span> $message . PHP_EOL;\n    }\n}\n\n$obj-&gt;setLogger(<span class=\"hljs-keyword\">new<\/span> ConsoleLogger());<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Now, you can make use the an anonymous class like this:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">$obj-&gt;setLogger(<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <\/span>{\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">log<\/span><span class=\"hljs-params\">($msg)<\/span> <\/span>{\n       <span class=\"hljs-keyword\">echo<\/span> $message . PHP_EOL;\n    }\n});<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Third, make a small optimization by avoid hitting the <a href=\"https:\/\/phptutorial.net\/php-oop\/php-autoloading-class-files\/\">autoloader<\/a> for trivial classes.<\/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 anonymous class is a class without a declared name.<\/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=\"2304\"\n\t\t\t\tdata-post-url=\"https:\/\/www.phptutorial.net\/php-oop\/php-anonymous-class\/\"\n\t\t\t\tdata-post-title=\"PHP Anonymous Class\"\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=\"2304\"\n\t\t\t\tdata-post-url=\"https:\/\/www.phptutorial.net\/php-oop\/php-anonymous-class\/\"\n\t\t\t\tdata-post-title=\"PHP Anonymous Class\"\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>In this tutorial, you&#8217;ll learn how about the PHP anonymous class and how to define anonymous classes.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1753,"menu_order":27,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2304","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/pages\/2304","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=2304"}],"version-history":[{"count":1,"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/pages\/2304\/revisions"}],"predecessor-version":[{"id":2305,"href":"https:\/\/www.phptutorial.net\/wp-json\/wp\/v2\/pages\/2304\/revisions\/2305"}],"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=2304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}