{"id":436,"date":"2025-06-10T20:25:06","date_gmt":"2025-06-10T12:25:06","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/php\/php-application-manual\/jcyy\/436.html"},"modified":"2025-06-10T20:25:06","modified_gmt":"2025-06-10T12:25:06","slug":"%e4%bf%ae%e5%a4%8d-php-%e9%94%99%e8%af%af%ef%bc%9a%e6%84%8f%e5%a4%96%e7%9a%84-t_string","status":"publish","type":"my1js","link":"https:\/\/www.zhaozhao123.cn\/php\/my1js\/436.html","title":{"rendered":"\u4fee\u590d PHP \u9519\u8bef\uff1a\u610f\u5916\u7684 T_STRING"},"content":{"rendered":"<p><body><\/p>\n<h2>&#20171;&#32461;<\/h2>\n<p>&#22312;&#20351;&#29992;PHP&#26102;&#65292;&#21487;&#33021;&#20250;&#36935;&#21040;&ldquo;Unexpected T_STRING&rdquo;&#38169;&#35823;&#12290;&#36825;&#36890;&#24120;&#26159;&#19968;&#20010;&#38590;&#20197;&#20811;&#26381;&#30340;&#38556;&#30861;&#65292;&#23588;&#20854;&#26159;&#22312;&#21021;&#23398;&#32773;&#20013;&#12290;&#36825;&#20010;&#38169;&#35823;&#36890;&#24120;&#34920;&#26126;PHP&#36935;&#21040;&#20102;&#19968;&#20010;&#23383;&#31526;&#20018;&#65292;&#20294;&#23427;&#24182;&#19981;&#26399;&#26395;&#20986;&#29616;&#36825;&#26679;&#30340;&#24773;&#20917;&#65292;&#24120;&#24120;&#26159;&#22240;&#20026;&#35821;&#27861;&#38169;&#35823;&#12290;&#22312;&#36825;&#31687;&#25351;&#21335;&#20013;&#65292;&#25105;&#20204;&#23558;&#25506;&#35752;&#23548;&#33268;&#36825;&#31181;&#38169;&#35823;&#30340;&#21407;&#22240;&#20197;&#21450;&#22914;&#20309;&#20462;&#22797;&#23427;&#12290;<\/p>\n<h2>&#29702;&#35299;T_STRING<\/h2>\n<p>&#8216;T_STRING&#8217; &#26159; PHP &#35299;&#26512;&#22120;&#30340;&#20998;&#38548;&#26426;&#21046;&#30340;&#19968;&#37096;&#20998;&#12290;&#20687;T_STRING` &#36825;&#26679;&#30340;&#20196;&#29260;&#26159;&#20869;&#37096;&#35299;&#26512;&#20195;&#30721;&#65292;&#34920;&#31034; PHP &#20195;&#30721;&#30340;&#19981;&#21516;&#20803;&#32032;&#12290;&#24403; PHP &#35828;&#23427;&#36935;&#21040;&#20102;&#19968;&#20010; &#8216;Unexpected T_STRING&#8217; &#26102;&#65292;&#36825;&#24847;&#21619;&#30528;&#23427;&#22312;&#20195;&#30721;&#20013;&#30340;&#26576;&#20010;&#22320;&#26041;&#25214;&#21040;&#20102;&#39044;&#26399;&#20043;&#22806;&#30340;&#23383;&#31526;&#20018;&#25991;&#26412;&#65292;&#36825;&#34920;&#26126;&#35821;&#27861;&#38169;&#35823;&#23384;&#22312;&#12290;<\/p>\n<h3>T_STRING &#38169;&#35823;&#30340;&#24120;&#35265;&#21407;&#22240;&#21253;&#25324;&#65306;1. &#24341;&#29992;&#23383;&#31526;&#20018;&#26102;&#27809;&#26377;&#27491;&#30830;&#22320;&#21021;&#22987;&#21270;&#23427;&#12290;2. &#22312;&#20351;&#29992;&#23383;&#31526;&#20018;&#20043;&#21069;&#65292;&#26410;&#36827;&#34892;&#27491;&#30830;&#30340;&#36171;&#20540;&#25110;&#36171;&#21021;&#20540;&#25805;&#20316;&#12290;3. &#20351;&#29992;&#20102;&#19981;&#25903;&#25345;&#30340;&#31867;&#22411;&#26469;&#24341;&#29992;&#23383;&#31526;&#20018;&#12290;4. &#27809;&#26377;&#22312;&#36866;&#24403;&#30340;&#22320;&#26041;&#35843;&#29992; free() &#20989;&#25968;&#26469;&#37322;&#25918;&#19981;&#20877;&#38656;&#35201;&#30340;&#20869;&#23384;&#12290;5. &#22312;&#22788;&#29702;&#23383;&#31526;&#20018;&#26102;&#21457;&#29983;&#20102;&#38169;&#35823;&#65292;&#20363;&#22914;&#38750;&#27861;&#23383;&#31526;&#34987;&#24847;&#22806;&#21253;&#21547;&#22312;&#23383;&#31526;&#20018;&#20013;&#12290;6. &#20351;&#29992;&#20102;&#24050;&#25439;&#22351;&#30340;&#23383;&#31526;&#20018;&#25351;&#38024;&#12290;7. &#35797;&#22270;&#35775;&#38382;&#19968;&#20010;&#19981;&#23384;&#22312;&#30340;&#25968;&#32452;&#20803;&#32032;&#12290;8. &#31243;&#24207;&#20013;&#30340;&#20854;&#20182;&#37096;&#20998;&#23548;&#33268;&#20102;&#20869;&#23384;&#27844;&#28431;&#12290;<\/h3>\n<p>&#22312;PHP&#20013;&#38169;&#35823;&#22320;&#35299;&#26512;HTML&#21487;&#33021;&#23548;&#33268;&#23433;&#20840;&#38382;&#39064;&#21644;&#21151;&#33021;&#22833;&#25928;&#12290;&#35831;&#30830;&#20445;&#20351;&#29992;&#27491;&#30830;&#30340;&#20989;&#25968;&#65292;&#22914;htmlspecialchars()&#26469;&#38450;&#27490;XSS&#25915;&#20987;&#65292;&#24182;&#20351;&#29992;DOMDocument&#25110;SimpleXML&#31561;&#24211;&#26469;&#27491;&#30830;&#35299;&#26512;HTML&#12290;<\/p>\n<p>&#26410;&#20851;&#38381;&#30340;&#27880;&#37322;<\/p>\n<p>&#32570;&#23569;&#25324;&#21495;&#25110;&#19981;&#27491;&#30830;&#30340;&#25324;&#21495;&#20351;&#29992;<\/p>\n<p>&#26410;&#38381;&#21512;&#30340;&#24341;&#21495;<\/p>\n<p>&#32570;&#23569;&#20998;&#21495;&#12290;<\/p>\n<h2>&#20197;&#19979;&#26159;&#20462;&#22797;T_STRING&#38169;&#35823;&#30340;&#27493;&#39588;&#25351;&#21335;&#65306;<\/h2>\n<p>&#30830;&#23450;&ldquo;Unexpected T_STRING&rdquo;&#38169;&#35823;&#30340;&#30830;&#20999;&#21407;&#22240;&#21487;&#33021;&#24456;&#22256;&#38590;&#65292;&#20294;&#25353;&#29031;&#20197;&#19979;&#27493;&#39588;&#21487;&#20197;&#24110;&#20320;&#25214;&#21040;&#24182;&#35299;&#20915;&#36825;&#20010;&#38382;&#39064;&#12290;<\/p>\n<h3>&#27493;&#39588;1 &#8211; &#26816;&#26597;&#32570;&#23569;&#30340;&#20998;&#21495;<\/h3>\n<p>PHP&#35821;&#21477;&#24212;&#20197;&#20998;&#21495;&#32467;&#26463;&#12290;&#32570;&#23569;&#20998;&#21495;&#21487;&#33021;&#23548;&#33268;PHP&#32487;&#32493;&#35835;&#21462;&#21040;&#19979;&#19968;&#34892;&#20195;&#30721;&#65292;&#20174;&#32780;&#24341;&#21457;&#35821;&#27861;&#38169;&#35823;&#12290;<\/p>\n<pre><code>&lt;?php\necho 'Hello, World'\n\/\/ Missing semicolon here can cause an error\necho 'This is a test'; \n?&gt;<\/code><\/pre>\n<p>&#30830;&#20445;&#27599;&#21477;&#35805;&#37117;&#20197;&#20998;&#21495;&#32467;&#23614;&#12290;<\/p>\n<h3>&#27493;&#39588;2 &#8211; &#23547;&#25214;&#26410;&#38381;&#21512;&#30340;&#24341;&#21495;<\/h3>\n<p>&#22312;&#23450;&#20041;&#23383;&#31526;&#20018;&#26102;&#65292;&#22987;&#32456;&#35201;&#30830;&#20445;&#24341;&#21495;&#34987;&#27491;&#30830;&#38381;&#21512;&#12290;<\/p>\n<pre><code>&lt;?php\necho 'This is a string; \n\/\/ Error! The string wasn't closed with a matching quote\necho \"Another string\";\n?&gt;<\/code><\/pre>\n<p>&#21305;&#37197;&#30340;&#24341;&#35821;&#21487;&#20197;&#38450;&#27490;T_STRING&#38169;&#35823;&#30340;&#21457;&#29983;&#12290;<\/p>\n<h3>&#27493;&#39588; 3 &#8211; &#39564;&#35777;&#25324;&#21495;&#21644;&#22278;&#25324;&#21495;<\/h3>\n<p>&#38169;&#35823;&#22320;&#20351;&#29992;&#25110;&#32570;&#22833;&#30340;&#25324;&#21495;&#12289;&#22278;&#25324;&#21495;&#25110;&#33457;&#25324;&#21495;&#20250;&#23548;&#33268;&#35821;&#27861;&#38169;&#35823;&#12290;&#27599;&#20010;&#24320;&#25324;&#21495;&#12289;&#22823;&#25324;&#21495;&#25110;&#33457;&#25324;&#21495;&#37117;&#24212;&#35813;&#26377;&#19968;&#20010;&#23545;&#24212;&#30340;&#38381;&#21512;&#23545;&#31561;&#29289;&#12290;<\/p>\n<pre><code>&lt;?php\nif ($a == $b) {\necho 'The values are equal';\n\/\/ Error! Missing closing brace\n?&gt;<\/code><\/pre>\n<p>&#26816;&#26597;&#24744;&#30340;&#26465;&#20214;&#21644;&#25511;&#21046;&#32467;&#26500;&#65292;&#20197;&#27491;&#30830;&#20351;&#29992;&#25324;&#21495;&#21644;&#22278;&#25324;&#21495;&#12290;<\/p>\n<h3>&#27493;&#39588;4 &#8211; &#30830;&#20445;&#35780;&#35770;&#34987;&#20851;&#38381;<\/h3>\n<p>&#22312;PHP&#20013;&#65292;&#27880;&#37322;&#26377;&#20004;&#31181;&#24418;&#24335;&#65306;&#21333;&#34892;&#65288;\/\/ &#25110; #&#65289;&#21644;&#22810;&#34892;&#65288;\/ \/&#65289;&#12290;&#22914;&#26524;&#24536;&#35760;&#38381;&#21512;&#19968;&#20010;&#22810;&#34892;&#27880;&#37322;&#65292;&#21017;&#21487;&#33021;&#20250;&#23548;&#33268;&#21518;&#32493;&#20195;&#30721;&#34987;&#35299;&#37322;&#20026;&#27880;&#37322;&#30340;&#19968;&#37096;&#20998;&#24182;&#25243;&#20986;&#38169;&#35823;&#12290;<\/p>\n<pre><code>&lt;?php\n\/* This is a multi-line comment\necho 'This will not be executed';\n\/\/ Error! Missing closing tag for the comment\n?&gt;<\/code><\/pre>\n<p>&#22987;&#32456;&#30830;&#20445;&#22810;&#34892;&#27880;&#37322;&#38381;&#21512;&#65292;&#20197;&#36991;&#20813;&#35821;&#27861;&#38169;&#35823;&#12290;<\/p>\n<h3>&#27493;&#39588; 5 &#8211; &#22312; PHP &#20013;&#27491;&#30830;&#35299;&#26512; HTML<\/h3>\n<p>&#22312;PHP&#20013;&#23884;&#20837;HTML&#20063;&#21487;&#33021;&#23548;&#33268;T_STRING&#38169;&#35823;&#12290;&#30830;&#20445;&#27491;&#30830;&#22320;&#20999;&#25442;&#21040;&#21644;&#20174;PHP&#27169;&#24335;&#26102;&#28151;&#21512;&#20351;&#29992;PHP&#19982;HTML&#12290;<\/p>\n<pre><code>&lt;?php\necho '&lt;div&gt;This is a div element&lt;\/div&gt;';\n\/\/ OR use standard HTML and the PHP closing tag\necho \"&lt;p&gt;This is a paragraph.&lt;\/p&gt;\";\n?&gt;\n&lt;p&gt;This is outside of the PHP tag.&lt;\/p&gt;<\/code><\/pre>\n<p>&#36825;&#30830;&#20445;&#20102;&#22312;PHP&#20195;&#30721;&#22359;&#20043;&#22806;&#65292;&#20320;&#30340;HTML&#34987;&#27491;&#30830;&#35299;&#26512;&#12290;<\/p>\n<h2>&#39069;&#22806;&#30340;&#25552;&#31034;<\/h2>\n<p>&#20180;&#32454;&#26597;&#30475;&#38169;&#35823;&#34892;&#25552;&#31034;&#65292;&#20294;&#35201;&#35760;&#20303;&#23454;&#38469;&#30340;&#38169;&#35823;&#21487;&#33021;&#22312;&#20195;&#30721;&#30340;&#26356;&#26089;&#20301;&#32622;&#12290;<\/p>\n<p>&#21551;&#29992;&#38169;&#35823;&#25253;&#21578;&#65292;&#35831;&#28155;&#21152;&#12290;<code>ini_set('display_errors', 1); error_reporting(E_ALL);<\/code>&#22312;&#32534;&#20889;&#21095;&#26412;&#36827;&#34892;&#24320;&#21457;&#26102;&#65292;&#20320;&#24212;&#35813;&#27880;&#24847;&#36825;&#20123;&#38382;&#39064;&#12290;<\/p>\n<p>&#20351;&#29992;&#24102;&#26377;&#35821;&#27861;&#39640;&#20142;&#26174;&#31034;&#30340;&#25991;&#26412;&#32534;&#36753;&#22120;&#25110;&#38598;&#25104;&#24320;&#21457;&#29615;&#22659;&#65288;IDE&#65289;&#21487;&#20197;&#24110;&#21161;&#24744;&#21457;&#29616;&#38169;&#35823;&#12290;<\/p>\n<h2>&#32467;&#35770;&#12290;<\/h2>\n<p>&#8220;&#22312;PHP&#20013;&#65292;&#24120;&#35265;&#30340;T_STRING&#38169;&#35823;&#36890;&#24120;&#24456;&#23481;&#26131;&#35299;&#20915;&#12290;&#36890;&#36807;&#20180;&#32454;&#38405;&#35835;&#38169;&#35823;&#28040;&#24687;&#24182;&#20180;&#32454;&#26816;&#26597;&#20195;&#30721;&#20013;&#30340;&#38382;&#39064;&#65292;&#20320;&#21487;&#20197;&#26816;&#27979;&#21040;&#19982;&#35821;&#27861;&#38382;&#39064;&#30456;&#20851;&#30340;&#20219;&#20309;&#38382;&#39064;&#12290;&#35760;&#20303;&#35201;&#26816;&#26597;&#24341;&#21495;&#12289;&#20998;&#21495;&#12289;&#33457;&#25324;&#21495;&#20197;&#21450;&#22914;&#20309;&#22312;PHP&#20013;&#35299;&#26512;HTML&#12290;&#20462;&#22797;&#38169;&#35823;&#28041;&#21450;&#32416;&#27491;&#35821;&#27861;&#38382;&#39064;&#65292;&#38543;&#30528;&#32451;&#20064;&#65292;&#20320;&#20250;&#21457;&#29616;&#20320;&#33021;&#26356;&#24555;&#22320;&#35299;&#20915;&#38382;&#39064;&#65292;&#32780;&#26080;&#38656;&#36153;&#21147;&#12290;&#8221;<\/p>\n<p>&#22987;&#32456;&#22312;&#21463;&#25511;&#29615;&#22659;&#20013;&#27979;&#35797;PHP&#20195;&#30721;&#65292;&#20197;&#38450;&#27490;&#22312;&#37096;&#32626;&#21040;&#29983;&#20135;&#26381;&#21153;&#22120;&#26102;&#20986;&#29616;&#38169;&#35823;&#12290;&#24320;&#24515;&#32534;&#31243;&#65281;<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#20171;&#32461; &#22312;&#20351;&#29992;PHP&#26102;&#65292;&#21487;&#33021;&#20250;&#36935;&#21040;&ldquo;Unexpected T_STRING&rdquo;&#38169;&#35823;&#12290;&#038;#3..<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"template":"","meta":{"_acf_changed":false},"tags":[],"my1js2nav":[38],"tuisongtax":[],"class_list":["post-436","my1js","type-my1js","status-publish","hentry","my1js2nav-jcyy"],"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\/436","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=436"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/tags?post=436"},{"taxonomy":"my1js2nav","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js2nav?post=436"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/tuisongtax?post=436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}