{"id":16613,"date":"2023-12-06T11:06:42","date_gmt":"2023-12-06T03:06:42","guid":{"rendered":"https:\/\/app.60day.cn\/appday\/?p=16613"},"modified":"2023-12-06T11:06:42","modified_gmt":"2023-12-06T03:06:42","slug":"php%e5%bc%80%e5%8f%91%e5%8e%9f%e7%94%9f%e5%ae%89%e5%8d%93app%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e7%9a%84%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/app.60day.cn\/appday\/kaifaapp\/16613\/","title":{"rendered":"php\u5f00\u53d1\u539f\u751f\u5b89\u5353app\u5982\u4f55\u5b9e\u73b0\u7684\uff1f"},"content":{"rendered":"<p><a href=\"https:\/\/www.anzhuoe.com\/\">\u5b89\u5353app<\/a>    <\/p>\n<p>\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u63a2\u8ba8\u4f7f\u7528PHP\u5f00\u53d1\u539f\u751fAndroid\u5e94\u7528\u7684\u6280\u5de7\u548c\u65b9\u6cd5\u3002PHP\u88ab\u5e7f\u6cdb\u7528\u4e8eweb\u5f00\u53d1\uff0c\u4f46\u5bf9\u4e8e\u79fb\u52a8\u5e94\u7528\u5f00\u53d1\uff0c\u6211\u4eec\u9700\u8981\u5b9e\u73b0\u6865\u63a5\u6280\u672f\u6765\u8fd0\u884cPHP\u4ee3\u7801\u3002\u8981\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\uff0c\u6211\u4eec\u5c06\u4f7f\u7528WebView\u548cPHP\u7684Android\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u670d\u52a1\u5668\u3002<\/p>\n<p>\u8bf7\u6ce8\u610f\uff0c\u4f7f\u7528PHP<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-04\/07\/10\/04386865193.jpg\" \/><\/figure>\n<\/p>\n<p>\u6784\u5efa\u539f\u751fAndroid\u5e94\u7528\u5e76\u4e0d\u662f\u6700\u4f73\u5b9e\u8df5\u3002\u76f8\u53cd\uff0c\u60a8\u5e94\u8be5\u8003\u8651\u4f7f\u7528\u4e13\u4e3a\u6b64\u76ee\u7684\u800c\u8bbe\u8ba1\u7684\u6846\u67b6\uff0c\u5982React Native\u3001Flutter\u7b49\u3002\u7136\u800c\uff0c\u4e86\u89e3\u8fd9\u79cd\u5b9e\u73b0\u65b9\u5f0f\u4e5f\u8bb8\u80fd\u5e2e\u52a9\u60a8\u7406\u89e3\u4e00\u4e9b\u5173\u4e8eAndroid\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u7684\u57fa\u672c\u539f\u7406\u3002<\/p>\n<p>\u6b65\u9aa41\uff1a\u5b89\u88c5Android Studio<\/p>\n<p>\u5728\u5f00\u59cb\u7f16\u5199\u4ee3\u7801\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Android Studio\uff0c\u5b83\u662fGoogle\u5b98\u65b9\u7684\u7528\u4e8e\u5f00\u53d1Android\u5e94\u7528\u7684\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3002\u4f60\u53ef\u4ee5\u4ece\u8fd9\u91cc\u4e0b\u8f7d\u5b83\uff1ahttps:\/\/developer.android.com\/studio<\/p>\n<p>\u6b65\u9aa42\uff1a\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Android\u9879\u76ee<\/p>\n<p>1. \u6253\u5f00Android Studio\u5e76\u9009\u62e9\u201cCreate New Project\u201d\u3002<\/p>\n<p>2. \u9009\u62e9\u4e00\u4e2a\u9879\u76ee\u6a21\u677f\uff0c\u4f8b\u5982\u201cEmpty Activity\u201d\u6a21\u677f\u3002<\/p>\n<p>3. \u5728\u201cProject name\u201d\u5b57\u6bb5\u4e2d\u8f93\u5165\u9879\u76ee\u540d\u79f0\uff0c\u5982\u201cPHPAndroidApp\u201d\uff0c\u7136\u540e\u6309\u201cFinish\u201d\u3002<\/p>\n<p>\u6b65\u9aa43\uff1a\u8bbe\u7f6e WebView<\/p>\n<p>\u73b0\u5728\u6211\u4eec\u8981\u5728Android\u9879\u76ee\u4e2d\u96c6\u6210\u4e00\u4e2a WebView \u7ec4\u4ef6\u6765\u52a0\u8f7d\u548c\u8fd0\u884c\u6211\u4eec\u7684PHPWeb\u5e94\u7528\u3002<\/p>\n<p>1. \u5728activity_main.xml\u6587\u4ef6\u91cc\u6dfb\u52a0\u4e00\u4e2aWebView\uff1a<\/p>\n<p>&#8220;`xml<\/p>\n<\/p>\n<p>        android:id=&#8221;@+id\/webview&#8221;<\/p>\n<p>        android:layout_width=&#8221;match_parent&#8221;<\/p>\n<p>        android:layout_height=&#8221;match_parent&#8221; \/&gt;<\/p>\n<p>&#8220;`<\/p>\n<p>2. \u8981\u4f7f\u7528W<a href=\"https:\/\/www.anzhuoe.com\/\">\u5b89\u5353APP\u5f00\u53d1<\/a>ebView\uff0c\u6211\u4eec\u9700\u8981\u5728MainActivity.java\u6587\u4ef6\u4e2d\u6dfb\u52a0WebView\u7ec4\u4ef6\uff0c\u5e76\u5141\u8bb8JavaScript\uff1a<\/p>\n<p>&#8220;`java<\/p>\n<p>\/\/&#8230;\u5176\u4ed6\u5bfc\u5165<\/p>\n<p>import android.webkit.WebView;<\/p>\n<p>import android.webkit.WebViewClient;<\/p>\n<p>public class MainActivity extends AppCompatActivity {<\/p>\n<p>    private WebView webView;<\/p>\n<p>    @Override<\/p>\n<p>    protected void onCreate(Bundle savedInstanceState) {<\/p>\n<p>        super.onCreate(savedInstanceState);<\/p>\n<p>        setContentView(R.layout.activity_main);<\/p>\n<p>        webView = findViewById(R.id.webview);<\/p>\n<p>        webView.setWebViewClient(new WebViewClient());<\/p>\n<p>        webView.getSettings().setJavaScriptEnabled(true);<\/p>\n<p>        webView.loadUrl(&#8220;http:\/\/10.0.2.2:8080&#8221;);<\/p>\n<p>    }<\/p>\n<p>    @Override<\/p>\n<p>    public void onBackPressed() {<\/p>\n<p>        if (webView.canGoBack()) {<\/p>\n<p>            webView.goBack();<\/p>\n<p>        } else {<\/p>\n<p>            super.onBackPressed();<\/p>\n<p>        }<\/p>\n<p>    }<\/p>\n<p>}<\/p>\n<p>&#8220;`<\/p>\n<p>\u6b65\u9aa44\uff1a\u642d\u5efa PHP \u5f00\u53d1\u73af\u5883<\/p>\n<p>\u6211\u4eec\u9700\u8981\u5728\u672c\u5730\u8fd0\u884c\u4e00\u4e2a\u7b80\u5355\u7684PHP\u5f00\u53d1\u670d\u52a1\u5668\u3002\u4f60\u53ef\u4ee5\u53c2\u8003\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>php -S 10.0.2.2:8080<\/p>\n<p>&#8220;`<\/p>\n<p>\u6b64\u547d\u4ee4\u5c06\u542f\u52a8\u4e00\u4e2a\u76d1\u542c\u572810.0.2.2\u5730\u5740\u548c8080\u7aef\u53e3\u7684PHP\u670d\u52a1\u5668\u3002\u5f53\u60a8\u5728\u6a21\u62df\u5668\u4e0a\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u5b83\u5c06\u663e\u793a\u60a8\u7684PHPWeb\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u6b65\u9aa45\uff1a\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u5728Android\u6a21\u62df\u5668\u4e0a\u6216\u5c06\u60a8\u7684\u624b\u673a\u8fde\u63a5\u5230\u8ba1\u7b97\u673a\u4e0a\u5e76\u542f\u7528\u201c\u5f00\u53d1\u8005\u9009\u9879\u201d\u6765\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u3002\u8fd0\u884c\u540e\uff0c\u4e0e\u4e4b\u524d\u5728\u672c\u5730\u670d\u52a1\u5668\u4e2d\u9884\u89c8\u7684PHP\u5e94\u7528\u5e94\u8be5\u4e00\u6837\u3002<\/p>\n<p>\u6ce8\u610f\uff1a\u8bf7\u786e\u4fdd\u60a8\u7684\u8bbe\u5907\u548c\u5f00\u53d1\u73af\u5883\u5904\u4e8e\u76f8\u540c\u7f51\u7edc\u4e0b\uff0c\u4ee5\u786e\u4fdd\u5b83\u4eec\u53ef\u4ee5\u76f8\u4e92\u8bbf\u95ee\u3002<\/p>\n<p>\u603b\u7ed3\uff1a<\/p>\n<p>\u8fd9\u4e2a\u6559\u7a0b\u7ed9\u4f60\u5c55\u793a\u4e86\u5982\u4f55\u5728Android\u5e94\u7528\u4e2d\u8fd0\u884cPHP\u4ee3\u7801\u3002\u4f46\u8bf7\u8bb0\u4f4f\uff0c\u8fd9\u5e76\u4e0d\u662f\u4e00\u79cd\u63a8\u8350\u7684\u5f00\u53d1\u65b9\u6cd5\u3002\u4e13\u95e8\u9488\u5bf9\u79fb\u52a8\u5f00\u53d1\u7684\u591a\u79cd\u6280\u672f\u548c\u6846\u67b6\u80fd\u63d0\u4f9b\u66f4\u597d\u7684\u6027\u80fd\u3001\u4f18\u5316\u548c\u7528\u6237\u4f53\u9a8c\u3002\u6b64\u65b9\u6cd5\u4e3b\u8981\u7528\u4e8e\u5b66\u4e60\u548c\u7814\u7a76\u76ee\u7684\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u63a2\u8ba8\u4f7f\u7528PHP\u5f00\u53d1\u539f\u751fAndroid\u5e94\u7528\u7684\u6280\u5de7\u548c\u65b9\u6cd5\u3002PHP\u88ab\u5e7f\u6cdb\u7528\u4e8eweb\u5f00\u53d1\uff0c\u4f46\u5bf9\u4e8e\u79fb\u52a8\u5e94\u7528\u5f00\u53d1\uff0c\u6211\u4eec\u9700\u8981\u5b9e\u73b0\u6865\u63a5\u6280\u672f\u6765\u8fd0\u884cPHP\u4ee3\u7801\u3002\u8981\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\uff0c\u6211\u4eec\u5c06\u4f7f\u7528WebView<\/p>\n","protected":false},"author":25,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[23459,84,26,152,23458],"topic":[],"class_list":["post-16613","post","type-post","status-publish","format-standard","hentry","category-kaifaapp","tag-app","tag-84","tag-26","tag-152"],"_links":{"self":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/16613","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/comments?post=16613"}],"version-history":[{"count":1,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/16613\/revisions"}],"predecessor-version":[{"id":16639,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/16613\/revisions\/16639"}],"wp:attachment":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/media?parent=16613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/categories?post=16613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/tags?post=16613"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/topic?post=16613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}