{"id":597,"date":"2025-06-11T10:31:06","date_gmt":"2025-06-11T02:31:06","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/php\/php-application-manual\/sjjg\/597.html"},"modified":"2025-06-11T10:31:06","modified_gmt":"2025-06-11T02:31:06","slug":"%e4%ba%86%e8%a7%a3php%e7%b1%bb%e4%b8%ad%e7%9a%84this%e5%85%b3%e9%94%ae%e5%ad%97%ef%bc%9a%e8%af%a6%e7%bb%86%e6%8c%87%e5%8d%97","status":"publish","type":"my1js","link":"https:\/\/www.zhaozhao123.cn\/php\/my1js\/597.html","title":{"rendered":"\u4e86\u89e3PHP\u7c7b\u4e2d\u7684\u2018this\u2019\u5173\u952e\u5b57\uff1a\u8be6\u7ec6\u6307\u5357"},"content":{"rendered":"<div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--1\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/dyA-1-400x300.jpg\" alt=\"Bug&#32534;&#35793;&#29422;\" class=\"wp-image-1842\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading my-0\" style=\"font-size:clamp(0.875rem, 0.875rem + ((1vw - 0.2rem) * 0.175), 1rem);\">Bug&#32534;&#35793;&#29422;<\/h2>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<p>&#26631;&#39064;&#65306;PHP&#31867;&#20013;&#30340;&lsquo;this&rsquo;&#20851;&#38190;&#23383;&#65306;&#35814;&#32454;&#25351;&#21335;<\/p>\n<p>&#22312;PHP&#32534;&#31243;&#20013;&#65292;<code>this<\/code>&#20851;&#38190;&#23383;&#29992;&#20110;&#35775;&#38382;&#24403;&#21069;&#23545;&#35937;&#30340;&#23646;&#24615;&#21644;&#26041;&#27861;&#12290;&#23427;&#22312;&#38754;&#21521;&#23545;&#35937;&#32534;&#31243;&#65288;OOP&#65289;&#20013;&#38750;&#24120;&#37325;&#35201;&#65292;&#22240;&#20026;&#23427;&#20801;&#35768;&#20320;&#22312;&#31867;&#20869;&#37096;&#35775;&#38382;&#20854;&#20182;&#25104;&#21592;&#21464;&#37327;&#21644;&#26041;&#27861;&#12290;&#19979;&#38754;&#25105;&#23558;&#35814;&#32454;&#20171;&#32461;&#22914;&#20309;&#20351;&#29992;<code>this<\/code>&#20851;&#38190;&#23383;&#12290;<\/p>\n<h3>1. &#31034;&#20363;&#20195;&#30721;<\/h3>\n<pre><code class=\"language-php\">&lt;?php\nclass Car {\n    \/\/ &#31867;&#21464;&#37327;\n    public $brand;\n    public $model;\n\n    \/\/ &#26500;&#36896;&#20989;&#25968;\n    public function __construct($brand, $model) {\n        $this-&gt;brand = $brand;\n        $this-&gt;model = $model;\n    }\n\n    \/\/ &#26041;&#27861;\n    public function displayInfo() {\n        echo \"Brand: \" . $this-&gt;brand . \", Model: \" . $this-&gt;model . \"&lt;br&gt;\";\n    }\n}\n\n\/\/ &#21019;&#24314;Car&#31867;&#30340;&#23545;&#35937;\n$myCar = new Car(\"Toyota\", \"Corolla\");\n\n\/\/ &#35843;&#29992;displayInfo&#26041;&#27861;\n$myCar-&gt;displayInfo();\n?&gt;<\/code><\/pre>\n<h3>2. <code>this<\/code>&#30340;&#20851;&#38190;&#23383;&#29992;&#36884;<\/h3>\n<ul>\n<li><strong>&#35775;&#38382;&#31867;&#21464;&#37327;<\/strong>&#65306;&#36890;&#36807;<code>this<\/code>&#20851;&#38190;&#23383;&#21487;&#20197;&#35775;&#38382;&#31867;&#30340;&#23454;&#20363;&#21464;&#37327;&#12290;<\/li>\n<li><strong>&#35843;&#29992;&#31867;&#30340;&#26041;&#27861;<\/strong>&#65306;&#36890;&#36807;<code>this<\/code>&#20851;&#38190;&#23383;&#21487;&#20197;&#35843;&#29992;&#31867;&#30340;&#23454;&#20363;&#26041;&#27861;&#12290;<\/li>\n<li><strong>&#26500;&#36896;&#20989;&#25968;&#21442;&#25968;<\/strong>&#65306;&#22312;&#26500;&#36896;&#20989;&#25968;&#20013;&#65292;<code>this<\/code>&#20851;&#38190;&#23383;&#29992;&#20110;&#21021;&#22987;&#21270;&#23454;&#20363;&#21464;&#37327;&#12290;<\/li>\n<\/ul>\n<h3>3. &#27880;&#24847;&#20107;&#39033;<\/h3>\n<ul>\n<li><code>this<\/code>&#20851;&#38190;&#23383;&#19981;&#33021;&#22312;&#38745;&#24577;&#26041;&#27861;&#20013;&#20351;&#29992;&#65292;&#22240;&#20026;&#38745;&#24577;&#26041;&#27861;&#27809;&#26377;&#35775;&#38382;&#23454;&#20363;&#21464;&#37327;&#25110;&#23454;&#20363;&#26041;&#27861;&#30340;&#33021;&#21147;&#12290;<\/li>\n<li><code>this<\/code>&#20851;&#38190;&#23383;&#21482;&#33021;&#22312;&#31867;&#30340;&#20869;&#37096;&#20351;&#29992;&#65292;&#19981;&#33021;&#22312;&#22806;&#37096;&#30452;&#25509;&#20351;&#29992;&#12290;<\/li>\n<\/ul>\n<h3>4. &#31034;&#20363;&#20195;&#30721;&#20013;&#30340;&#27880;&#24847;&#20107;&#39033;<\/h3>\n<pre><code class=\"language-php\">&lt;?php\nclass Calculator {\n    private $value;\n\n    public function setValue($value) {\n        $this-&gt;value = $value;\n    }\n\n    public function getValue() {\n        return $this-&gt;value;\n    }\n\n    public function add($num) {\n        $this-&gt;value += $num;\n    }\n\n    public function subtract($num) {\n        $this-&gt;value -= $num;\n    }\n\n    public function multiply($num) {\n        $this-&gt;value *= $num;\n    }\n\n    public function divide($num) {\n        if ($num != 0) {\n            $this-&gt;value \/= $num;\n        } else {\n            echo \"Error: Division by zero is not allowed.\";\n        }\n    }\n}\n\n\/\/ &#21019;&#24314;Calculator&#31867;&#30340;&#23545;&#35937;\n$calc = new Calculator();\n\n\/\/ &#35774;&#32622;&#20540;\n$calc-&gt;setValue(10);\n\n\/\/ &#25191;&#34892;&#25805;&#20316;\n$calc-&gt;add(5);\n$calc-&gt;subtract(3);\n$calc-&gt;multiply(2);\n$calc-&gt;divide(2);\n\n\/\/ &#36755;&#20986;&#32467;&#26524;\necho \"Final Value: \" . $calc-&gt;getValue();\n?&gt;<\/code><\/pre>\n<p>&#22312;&#36825;&#20010;&#20363;&#23376;&#20013;&#65292;&#25105;&#20204;&#23637;&#31034;&#20102;&#22914;&#20309;&#20351;&#29992;<code>this<\/code>&#20851;&#38190;&#23383;&#26469;&#31649;&#29702;&#31867;&#30340;&#23454;&#20363;&#21464;&#37327;&#21644;&#26041;&#27861;&#65292;&#24182;&#19988;&#22312;&#38656;&#35201;&#26102;&#25191;&#34892;&#25968;&#23398;&#36816;&#31639;&#12290;<\/p>\n<p>&#36890;&#36807;&#29702;&#35299;<code>this<\/code>&#20851;&#38190;&#23383;&#30340;&#22522;&#26412;&#29992;&#27861;&#65292;&#20320;&#21487;&#20197;&#26356;&#22909;&#22320;&#32534;&#20889;&#21644;&#32500;&#25252;PHP&#30340;&#38754;&#21521;&#23545;&#35937;&#31243;&#24207;&#12290;&#24076;&#26395;&#36825;&#20010;&#25351;&#21335;&#23545;&#20320;&#26377;&#25152;&#24110;&#21161;&#65281;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div><div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--2\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/zp-400x300.jpg\" alt=\"&#40657;&#26495;Bug&#35762;&#24072;\" class=\"wp-image-1849\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading my-0\" style=\"font-size:clamp(0.875rem, 0.875rem + ((1vw - 0.2rem) * 0.175), 1rem);\">&#40657;&#26495;Bug&#35762;&#24072;<\/h2>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<body><h2>&#20171;&#32461;<\/h2><p>&#22312; PHP &#20013;&#20351;&#29992;&#38754;&#21521;&#23545;&#35937;&#32534;&#31243;&#65288;OOP&#65289;&#23545;&#20110;&#26500;&#24314;&#21487;&#25193;&#23637;&#21644;&#32500;&#25252;&#30340; Web &#24212;&#29992;&#31243;&#24207;&#33267;&#20851;&#37325;&#35201;&#12290;&#38754;&#21521;&#23545;&#35937;&#32534;&#31243;&#65288;OOP&#65289;&#30340;&#27010;&#24565;&#22312; PHP &#20013;&#26159;&#19968;&#20010;&#20851;&#38190;&#28857;&#12290;<code>this<\/code>&#20851;&#38190;&#35789;&#65292;&#23545;&#20110;&#21021;&#23398;&#32773;&#21644;&#32463;&#39564;&#20016;&#23500;&#30340;&#24320;&#21457;&#20154;&#21592;&#26469;&#35828;&#26377;&#26102;&#21487;&#33021;&#20250;&#24341;&#36215;&#28151;&#28102;&#12290;&#26412;&#25351;&#21335;&#23558;&#25552;&#20379;&#23545;&#36825;&#20123;&#20851;&#38190;&#23383;&#30340;&#28145;&#20837;&#29702;&#35299;&#12290;<code>this<\/code>&#22312;PHP&#31867;&#30340;&#19978;&#19979;&#25991;&#20013;&#65292;&#20851;&#38190;&#35789;&#12290;<\/p><h2>&#20851;&#38190;&#35789;&ldquo;this&rdquo;&#65306;&#28145;&#20837;&#35299;&#26512;<\/h2><p>&#23545;&#19981;&#36215;&#65292;&#24744;&#30340;&#38382;&#39064;&#19981;&#22815;&#26126;&#30830;&#12290;&#35831;&#25552;&#20379;&#26356;&#22810;&#30340;&#20449;&#24687;&#25110;&#37325;&#26032;&#25551;&#36848;&#24744;&#30340;&#38382;&#39064;&#12290;<code>this<\/code>&#22312;PHP&#20013;&#65292;&#20851;&#38190;&#23383;$this&#29992;&#20110;&#25351;&#21521;&#24403;&#21069;&#31867;&#20013;&#30340;&#23545;&#35937;&#23454;&#20363;&#12290;&#23427;&#29992;&#20110;&#35775;&#38382;&#24403;&#21069;&#23545;&#35937;&#23454;&#20363;&#30340;&#23646;&#24615;&#21644;&#26041;&#27861;&#12290;&#36825;&#20010;&#24341;&#29992;&#20165;&#22312;&#31867;&#30340;&#26041;&#27861;&#20869;&#37096;&#21487;&#29992;&#65292;&#24182;&#20801;&#35768;&#24744;&#19982;&#20854;&#20182;&#21516;&#19968;&#31867;&#25104;&#21592;&#36827;&#34892;&#20132;&#20114;&#12290;<\/p><h3>&#35775;&#38382;&#24102;&#26377;&ldquo;this&rdquo;&#30340;&#23646;&#24615;<\/h3><p>&#23646;&#24615;&#26159;&#22312;&#31867;&#20869;&#37096;&#23450;&#20041;&#30340;&#21464;&#37327;&#65292;&#23427;&#20204;&#20195;&#34920;&#23545;&#35937;&#30340;&#29366;&#24577;&#12290;<code>this<\/code>&#20851;&#38190;&#23383;&#29992;&#20110;&#22312;&#31867;&#26041;&#27861;&#20869;&#37096;&#35775;&#38382;&#36825;&#20123;&#23646;&#24615;&#65306;<\/p><pre><code>class Car {\n  public $model;\n\n  public function setModel($model) {\n    $this-&gt;model = $model;\n  }\n\n  public function getModel() {\n    return $this-&gt;model;\n  }\n}\n\n$car = new Car();\n$car-&gt;setModel('Tesla Model 3');\n\necho $car-&gt;getModel();  \/\/ Outputs: Tesla Model 3\n<\/code><\/pre><h3>&#29702;&#35299;&#26041;&#27861;&#20013;&#30340;&ldquo;this&rdquo;<\/h3><p>&#26041;&#27861;&#26159;&#22312;&#31867;&#20869;&#37096;&#23450;&#20041;&#30340;&#34892;&#20026;&#65292;&#23427;&#20204;&#20915;&#23450;&#20102;&#23545;&#35937;&#30340;&#34892;&#20026;&#12290;<code>this<\/code>&#20851;&#38190;&#23383;keyword&#25552;&#20379;&#20102;&#19968;&#31181;&#22312;&#21516;&#19968;&#20010;&#23545;&#35937;&#20869;&#37096;&#35843;&#29992;&#21478;&#19968;&#20010;&#26041;&#27861;&#30340;&#26041;&#24335;&#65306;<\/p><pre><code>class Person {\n  public function getName() {\n    return \"John\";\n  }\n\n  public function greet() {\n    echo \"Hello, \" . $this-&gt;getName();\n  }\n}\n\n$person = new Person();\n$person-&gt;greet();  \/\/ Outputs: Hello, John\n<\/code><\/pre><h3>&#20026;&#20160;&#20040;&#20351;&#29992;&ldquo;this&rdquo;&#32780;&#19981;&#26159;&#23545;&#35937;&#21517;&#65311;<\/h3><p>&#20154;&#20204;&#21487;&#33021;&#20250;&#22909;&#22855;&#25105;&#20204;&#20026;&#20160;&#20040;&#38656;&#35201;&#20351;&#29992;<code>this<\/code>&#32780;&#19981;&#26159;&#36890;&#36807;&#21517;&#31216;&#26469;&#24341;&#29992;&#23545;&#35937;&#12290;&#32771;&#34385;&#20197;&#19979;&#24773;&#20917;&#65306;<\/p><pre><code>class Book {\n  public $title;\n\n  public function setTitle($title) {\n    $this-&gt;title = $title;\n  }\n\n  public function getTitle() {\n    return $this-&gt;title;\n  }\n}\n\n$book1 = new Book();\n$book1-&gt;setTitle('PHP Handbook');\n\n$book2 = new Book();\n$book2-&gt;setTitle('JavaScript Guide');\n\n\/\/ Now, if you wanted to refer to the object by name, you would have to write:\n\/\/ $book1-&gt;title and $book2-&gt;title\n\/\/ Whereas using $this-&gt;title handles it dynamically for the current instance, irrespective of the object's name.\n<\/code><\/pre><h3>&ldquo;this&rdquo;&#21644;$this::&#35201;&#23567;&#24515;&#35821;&#27861;&#12290;<\/h3><p>&#35821;&#27861;&#22312;&#22788;&#29702;&#26102;&#38750;&#24120;&#37325;&#35201;&#12290;<code>this<\/code>&#22312;PHP&#20013;&#65292;&#20851;&#38190;&#23383;&ldquo;keyword&rdquo;&#24635;&#26159;&#19982;-&gt;&#36816;&#31639;&#31526;&#19968;&#36215;&#20351;&#29992;&#26469;&#35775;&#38382;&#23646;&#24615;&#25110;&#26041;&#27861;&#12290;<code>this<\/code>&#21333;&#29420;&#20351;&#29992;&#23601;&#20250;&#24341;&#21457;&#35821;&#27861;&#38169;&#35823;&#12290;<\/p><h3>&#32487;&#25215;&#21644;&ldquo;this&rdquo;<\/h3><p>&#32487;&#25215;&#20801;&#35768;&#31867;&#20174;&#21478;&#19968;&#20010;&#31867;&#32487;&#25215;&#23646;&#24615;&#21644;&#26041;&#27861;&#12290;&#21363;&#20351;&#22312;&#32487;&#25215;&#30340;&#26041;&#27861;&#20869;&#37096;&#65292;&#20063;&#26159;&#22914;&#27492;&#12290;<code>this<\/code>&#25351;&#30340;&#26159;&#24403;&#21069;&#23454;&#20363;&#30340;&#23376;&#31867;&#65306;<\/p><pre><code>class Vehicle {\n  protected $brand;\n\n  public function setBrand($brand) {\n    $this-&gt;brand = $brand;\n  }\n}\n\nclass Car extends Vehicle {\n  public function getBrand() {\n    return $this-&gt;brand;\n  }\n}\n\n$car = new Car();\n$car-&gt;setBrand('Audi');\n\necho $car-&gt;getBrand();  \/\/ Outputs: Audi\n<\/code><\/pre><h3>&#22312;&#19981;&#21516;&#30340;&#19978;&#19979;&#25991;&#20013;&#65292;&ldquo;this&rdquo;&#26377;&#19981;&#21516;&#30340;&#21547;&#20041;&#12290;<\/h3><p>&#20320;&#22909;&#12290;<code>this<\/code>&#34892;&#20026;&#22312;&#20351;&#29992;&#22330;&#21512;&#19981;&#21516;&#24773;&#20917;&#19979;&#21487;&#33021;&#20250;&#26377;&#25152;&#21464;&#21270;&#65306;<\/p><p>&#22312;&#38745;&#24577;&#26041;&#27861;&#20013;&#65292;<code>this<\/code>&#38745;&#24577;&#26041;&#27861;&#19981;&#33021;&#36890;&#36807;&#31867;&#30340;&#23454;&#20363;&#35843;&#29992;&#65292;&#22240;&#27492;&#35813;&#21151;&#33021;&#19981;&#21487;&#29992;&#12290;<\/p><p>&#22312;&#38750;&#38745;&#24577;&#26041;&#27861;&#20013;&#65292;<code>this<\/code>&#23427;&#25351;&#30340;&#26159;&#24403;&#21069;&#23454;&#20363;&#30340;&#31867;&#12290;<\/p><h3>&#38745;&#24577;&#19978;&#19979;&#25991;&#21644;&ldquo;this&rdquo;&#30340;&#26367;&#20195;&#35789;<\/h3><p>&#22312;&#22788;&#29702;&#38745;&#24577;&#26041;&#27861;&#21644;&#23646;&#24615;&#26102;&#65292;&#32780;&#19981;&#26159;&#20351;&#29992;<code>this<\/code>&#25105;&#20204;&#20351;&#29992;&#30340;&#26159;&#12290;<code>self::<\/code>&#20851;&#38190;&#23383;&#19982;&#20316;&#29992;&#22495;&#35299;&#26512;&#36816;&#31639;&#31526;<code>::<\/code>&#35201;&#22312;&#31867;&#20869;&#37096;&#35775;&#38382;&#38745;&#24577;&#23646;&#24615;&#25110;&#26041;&#27861;&#65306;<\/p><pre><code>class Calculator {\n  protected static $lastResult;\n\n  public static function add($a, $b) {\n    self::$lastResult = $a + $b;\n    return self::$lastResult;\n  }\n}\n\nCalculator::add(5, 10); \/\/ Calls static method without using $this\n<\/code><\/pre><h3>&ldquo;this&rdquo; &#21644;&#20316;&#29992;&#22495;&#35299;&#26512;&#36816;&#31639;&#31526;<\/h3><p>&#24456;&#37325;&#35201;&#30340;&#26159;&#19981;&#35201;&#28151;&#28102;<code>this<\/code>&#20351;&#29992;&#33539;&#22260;&#36816;&#31639;&#31526;&#12290;<code>::<\/code>&#35813;&#25509;&#21475;&#29992;&#20110;&#35775;&#38382;&#29238;&#31867;&#20013;&#30340;&#38745;&#24577;&#12289;&#24120;&#37327;&#21644;&#35206;&#30422;&#26041;&#27861;&#30340;&#25104;&#21592;&#12290;<\/p><h2>&#32467;&#35770;&#12290;<\/h2><p>&#25484;&#25569;&#20351;&#29992;&#30340;&#26041;&#27861;&#26159;&#20851;&#38190;&#12290;<code>this<\/code>&#20851;&#38190;&#35789;&#23545;&#20110;&#20351;&#29992;PHP&#30340;&#38754;&#21521;&#23545;&#35937;&#32534;&#31243;&#33267;&#20851;&#37325;&#35201;&#12290;&#23427;&#20801;&#35768;&#20320;&#32534;&#20889;&#19981;&#20165;&#21151;&#33021;&#24615;&#24378;&#65292;&#32780;&#19988;&#20195;&#30721;&#25972;&#27905;&#12289;&#24847;&#22270;&#26126;&#30830;&#30340;&#20195;&#30721;&#12290;&#29702;&#35299;&#22914;&#20309;&#36816;&#29992;&#36825;&#20123;&#27010;&#24565;&#26159;&#33267;&#20851;&#37325;&#35201;&#30340;&#12290;<code>this<\/code>&#22312;&#19981;&#21516;&#30340;&#31867;&#26041;&#27861;&#19978;&#19979;&#25991;&#20013;&#25805;&#20316;&#21487;&#20197;&#24110;&#21161;&#24744;&#36991;&#20813;&#24120;&#35265;&#30340;&#38519;&#38449;&#24182;&#25552;&#39640;PHP&#24212;&#29992;&#31243;&#24207;&#30340;&#32467;&#26500;&#21644;&#21487;&#38752;&#24615;&#12290;<\/p><p>&#21644;&#25152;&#26377;&#32534;&#31243;&#25216;&#33021;&#19968;&#26679;&#65292;&#23454;&#36341;&#33267;&#20851;&#37325;&#35201;&#12290;&#35797;&#30528;&#33258;&#24049;&#21019;&#24314;&#31867;&#12289;&#26041;&#27861;&#21644;&#23646;&#24615;&#26469;&#25506;&#32034;&#23427;&#20204;&#30340;&#20351;&#29992;&#12290;<code>this<\/code>&#22312;&#21508;&#31181;&#22330;&#26223;&#19979;&#12290;&#24456;&#24555;&#65292;&#22788;&#29702;<code>this<\/code>&#22312;&#20320;&#30340;PHP&#24320;&#21457;&#36807;&#31243;&#20013;&#65292;&#36825;&#23558;&#25104;&#20026;&#31532;&#20108;&#33258;&#28982;&#12290;<\/p><\/body>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div><div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--3\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/xygcfznnzczhsdmwydzhsmzzzmddnq-400x300.jpg\" alt=\"&#38271;&#24037;&#30721;&#22900;1523\" class=\"wp-image-2906\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading my-0\" style=\"font-size:clamp(0.875rem, 0.875rem + ((1vw - 0.2rem) * 0.175), 1rem);\">&#38271;&#24037;&#30721;&#22900;1523<\/h2>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<p><code>this<\/code> &#22312; PHP &#31867;&#20013;&#26159;&#19968;&#31181;&#29305;&#27530;&#30340;&#23545;&#35937;&#24341;&#29992;&#65292;&#23427;&#20195;&#34920;&#24403;&#21069;&#25191;&#34892;&#26041;&#27861;&#30340;&#23454;&#20363;&#26412;&#36523;&#12290;&#24403;&#20320;&#38656;&#35201;&#35775;&#38382;&#21644;&#25805;&#20316;&#35813;&#23454;&#20363;&#30340;&#23646;&#24615;&#26102;&#65292;&#21487;&#20197;&#20351;&#29992; <code>this<\/code> &#20851;&#38190;&#23383;&#12290;<\/p>\n<h3>&#20160;&#20040;&#26159; <code>this<\/code>&#65311;<\/h3>\n<ul>\n<li><strong>&#20316;&#29992;&#22495;<\/strong>&#65306;<code>this<\/code> &#20851;&#38190;&#23383;&#30340;&#20316;&#29992;&#22495;&#19982;&#31867;&#30340;&#25104;&#21592;&#21464;&#37327;&#65288;&#22914;&#23646;&#24615;&#65289;&#30456;&#21516;&#12290;<\/li>\n<li><strong>&#20351;&#29992;&#22330;&#26223;<\/strong>&#65306;\n<ul>\n<li>&#24403;&#20320;&#38656;&#35201;&#35775;&#38382;&#31867;&#30340;&#23454;&#20363;&#23646;&#24615;&#26102;&#65292;&#27604;&#22914;&#36890;&#36807;&#35843;&#29992;&#31867;&#30340;&#26041;&#27861;&#26469;&#33719;&#21462;&#25110;&#32773;&#35774;&#32622;&#36825;&#20123;&#23646;&#24615;&#30340;&#20540;&#12290;<\/li>\n<li>&#20351;&#29992; <code>this<\/code> &#21487;&#20197;&#36991;&#20813;&#30452;&#25509;&#35775;&#38382;&#31169;&#26377;&#25110;&#20445;&#25252;&#23646;&#24615;&#65292;&#20174;&#32780;&#20445;&#35777;&#20102;&#25968;&#25454;&#30340;&#23433;&#20840;&#24615;&#12290;<\/li>\n<\/ul><\/li>\n<\/ul>\n<h3>&#22914;&#20309;&#20351;&#29992; <code>this<\/code>&#65311;<\/h3>\n<ol>\n<li>\n<p>&#22312;&#31867;&#26041;&#27861;&#20869;&#37096;&#20351;&#29992; <code>this<\/code>&#65306;<\/p>\n<pre><code class=\"language-php\">class MyClass {\n   public function myMethod() {\n       \/\/ &#20351;&#29992; this &#35775;&#38382;&#23454;&#20363;&#30340;&#31169;&#26377;&#23646;&#24615;\n       $privateProperty = $this-&gt;getPrivateProperty();\n       echo \"This is the private property: \" . $privateProperty;\n   }\n}\n\n$myInstance = new MyClass();\n$myInstance-&gt;myMethod(); \/\/ &#36755;&#20986;: This is the private property: null<\/code><\/pre>\n<\/li>\n<li>\n<p>&#22312;&#26500;&#36896;&#20989;&#25968;&#20013;&#20351;&#29992; <code>this<\/code>&#65306;<\/p>\n<pre><code class=\"language-php\">class MyClass {\n   private $privateProperty;\n\n   public function __construct($initialValue) {\n       $this-&gt;privateProperty = $initialValue;\n   }\n\n   public function myMethod() {\n       \/\/ &#20351;&#29992; this &#35775;&#38382;&#23454;&#20363;&#30340;&#31169;&#26377;&#23646;&#24615;\n       echo \"This is the instance's private property: \" . $this-&gt;privateProperty;\n   }\n}\n\n$myInstance = new MyClass(\"Hello\");\n$myInstance-&gt;myMethod(); \/\/ &#36755;&#20986;: This is the instance's private property: Hello<\/code><\/pre>\n<\/li>\n<li>\n<p>&#22312;&#31867;&#26041;&#27861;&#20013;&#20351;&#29992; <code>this<\/code>&#65306;<\/p>\n<pre><code class=\"language-php\">class MyClass {\n   public function myMethod() {\n       $this-&gt;doSomethingElse();\n   }\n\n   protected function doSomethingElse() {\n       \/\/ &#20351;&#29992; this &#35775;&#38382;&#31867;&#30340;&#20844;&#20849;&#26041;&#27861;\n       echo \"This is an external method: \";\n       echo get_class($this);\n   }\n}\n\n$myInstance = new MyClass();\n$myInstance-&gt;myMethod(); \/\/ &#36755;&#20986;: MyClass<\/code><\/pre>\n<\/li>\n<\/ol>\n<h3>&#31034;&#20363;&#20195;&#30721;<\/h3>\n<pre><code class=\"language-php\">class MyClass {\n    private $privateProperty;\n\n    public function __construct($initialValue) {\n        $this-&gt;privateProperty = $initialValue;\n    }\n\n    public function myMethod() {\n        echo \"This is the instance's private property: \" . $this-&gt;privateProperty . \"n\";\n    }\n}\n\n$myInstance = new MyClass(5); \/\/ &#21019;&#24314;&#23454;&#20363;&#24182;&#35774;&#32622;&#31169;&#26377;&#23646;&#24615;\n$myInstance-&gt;myMethod(); \/\/ &#36755;&#20986;: This is the instance's private property: 5<\/code><\/pre>\n<p>&#36890;&#36807;&#19978;&#36848;&#31034;&#20363;&#65292;&#20320;&#21487;&#20197;&#30475;&#21040;&#22914;&#20309;&#20351;&#29992; <code>this<\/code> &#20851;&#38190;&#23383;&#26469;&#35775;&#38382;&#21644;&#25805;&#20316;&#31867;&#30340;&#23454;&#20363;&#23646;&#24615;&#12290;&#36825;&#31181;&#20570;&#27861;&#30830;&#20445;&#20102;&#25968;&#25454;&#23433;&#20840;&#24615;&#21644;&#25552;&#39640;&#20195;&#30721;&#30340;&#21487;&#35835;&#24615;&#12290;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Bug&#32534;&#35793;&#29422; &#26631;&#39064;&#65306;PHP&#31867;&#20013;&#30340;&lsquo;this&rsquo;&#20851;&#38190;&#23383;&#65306;&#35814;&#32454;&#25351;&#038;#21335..<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"template":"","meta":{"_acf_changed":false},"tags":[],"my1js2nav":[41],"tuisongtax":[],"class_list":["post-597","my1js","type-my1js","status-publish","hentry","my1js2nav-sjjg"],"acf":{"qian_art_seotitle":"","qian_art_seotitle_source":{"label":"SEO\u6807\u9898","type":"text","formatted_value":""},"qian_art_seokws":"","qian_art_seokws_source":{"label":"SEO\u5173\u952e\u8bcd","type":"text","formatted_value":""},"qian_art_stzhong":"","qian_art_stzhong_source":{"label":"\u4e2d | \u77ed\u6807\u9898","type":"text","formatted_value":""}},"_links":{"self":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js\/597","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js"}],"about":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/types\/my1js"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/users\/1"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/media?parent=597"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/tags?post=597"},{"taxonomy":"my1js2nav","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js2nav?post=597"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/tuisongtax?post=597"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}