{"id":25988,"date":"2024-11-24T14:47:52","date_gmt":"2024-11-24T06:47:52","guid":{"rendered":"https:\/\/fwq.ai\/blog\/25988\/"},"modified":"2024-11-24T14:47:52","modified_gmt":"2024-11-24T06:47:52","slug":"html%e4%b8%ad%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8php%e6%9d%a1%e4%bb%b6%e5%88%a4%e6%96%ad%e4%bf%ae%e6%94%b9input%e5%85%83%e7%b4%a0%e7%9a%84readonly%e5%b1%9e%e6%80%a7%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/25988\/","title":{"rendered":"HTML\u4e2d\u5982\u4f55\u4f7f\u7528PHP\u6761\u4ef6\u5224\u65ad\u4fee\u6539input\u5143\u7d20\u7684readOnly\u5c5e\u6027\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173077021396426.jpg\" class=\"aligncenter\" title=\"HTML\u4e2d\u5982\u4f55\u4f7f\u7528PHP\u6761\u4ef6\u5224\u65ad\u4fee\u6539input\u5143\u7d20\u7684readOnly\u5c5e\u6027\uff1f\u63d2\u56fe\" alt=\"HTML\u4e2d\u5982\u4f55\u4f7f\u7528PHP\u6761\u4ef6\u5224\u65ad\u4fee\u6539input\u5143\u7d20\u7684readOnly\u5c5e\u6027\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4e0d\u53ef\u4fee\u6539readonly\u5c5e\u6027\uff1f<\/strong><\/p>\n<p>\u5728HTML\u4e2d\uff0c\u60f3\u4f7f\u7528PHP\u6761\u4ef6\u5224\u65ad\u6765\u4fee\u6539\u5143\u7d20\u7684readOnly\u5c5e\u6027\uff0c\u4f46\u53d1\u73b0\u4e0d\u8d77\u4f5c\u7528\uff0c\u8be5\u5982\u4f55\u4fee\u6539\uff1f<\/p>\n<p><strong>\u662f\u5426\u53ea\u80fd\u7528JS\u4fee\u6539readOnly\uff1f<\/strong><\/p>\n<p>readOnly\u5c5e\u6027\u7684\u503c\u5e76\u975e\u7531true\u6216false\u63a7\u5236\uff0c\u53ea\u8981\u6709readOnly\uff0c\u4e0d\u7ba1\u540e\u9762\u7684\u503c\u662f\u4ec0\u4e48\uff0c\u8f93\u5165\u5143\u7d20\u90fd\u662f\u4e0d\u53ef\u4fee\u6539\u7684\u3002<\/p>\n<p><strong>\u6b63\u786e\u4fee\u6539\u65b9\u6cd5<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u5e94\u8be5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u6765\u4fee\u6539readOnly\u5c5e\u6027\uff1a<\/p>\n<pre>&lt;input type=\"text\" value=\"&lt;?php echo $_GET['userName'] ?? '';?&gt;\" &lt;?php print(isset($_GET['userName']) ? 'readonly':''); ?&gt; &gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u884c\u4ee3\u7801\u4f7f\u7528isset()\u51fd\u6570\u6765\u68c0\u67e5$_GET[&#8216;userName&#8217;]\u662f\u5426\u5b58\u5728\uff0c\u5982\u679c\u5b58\u5728\uff0c\u5c06readOnly\u5c5e\u6027\u8bbe\u7f6e\u4e3areadonly\uff0c\u5426\u5219\u4e0d\u8bbe\u7f6e\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fHTML\u4e2d\u5982\u4f55\u4f7f\u7528PHP\u6761\u4ef6\u5224\u65ad\u4fee\u6539input\u5143\u7d20\u7684readOnly\u5c5e\u6027\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0d\u53ef\u4fee\u6539readonly\u5c5e\u6027\uff1f \u5728HTML\u4e2d\uff0c\u60f3\u4f7f\u7528PHP\u6761\u4ef6\u5224\u65ad\u6765\u4fee\u6539\u5143\u7d20\u7684readOnly\u5c5e\u6027\uff0c\u4f46\u53d1\u73b0\u4e0d\u8d77\u4f5c\u7528\uff0c\u8be5\u5982\u4f55\u4fee\u6539\uff1f \u662f\u5426\u53ea\u80fd\u7528JS\u4fee\u6539readOnly\uff1f readOnly\u5c5e\u6027\u7684\u503c\u5e76\u975e\u7531true\u6216false\u63a7\u5236\uff0c\u53ea\u8981\u6709readOnly\uff0c\u4e0d\u7ba1\u540e\u9762\u7684\u503c\u662f\u4ec0\u4e48\uff0c\u8f93\u5165\u5143\u7d20\u90fd\u662f\u4e0d\u53ef\u4fee\u6539\u7684\u3002 \u6b63\u786e\u4fee\u6539\u65b9\u6cd5 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u5e94\u8be5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u6765\u4fee\u6539readOnly\u5c5e\u6027\uff1a &lt;input type=&#8221;text&#8221; value=&#8221;&lt;?php echo $_GET[&#8216;userName&#8217;] ?? &#8221;;?&gt;&#8221; &lt;?php print(isset($_GET[&#8216;userName&#8217;]) ? &#8216;readonly&#8217;:&#8221;); ?&gt; &gt; \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u884c\u4ee3\u7801\u4f7f\u7528isset()\u51fd\u6570\u6765\u68c0\u67e5$_GET[&#8216;userName&#8217;]\u662f\u5426\u5b58\u5728\uff0c\u5982\u679c\u5b58\u5728\uff0c\u5c06readOnly\u5c5e\u6027\u8bbe\u7f6e\u4e3areadonly\uff0c\u5426\u5219\u4e0d\u8bbe\u7f6e\u3002 \u4ee5\u4e0a\u5c31\u662fHTML\u4e2d\u5982\u4f55\u4f7f\u7528PHP\u6761\u4ef6\u5224\u65ad\u4fee\u6539input\u5143\u7d20\u7684readOnly\u5c5e\u6027\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-25988","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25988","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=25988"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25988\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=25988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=25988"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=25988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}