{"id":443,"date":"2020-03-19T17:03:06","date_gmt":"2020-03-19T09:03:06","guid":{"rendered":"http:\/\/124.244.86.40:8080\/wordpress\/?p=443"},"modified":"2020-03-19T17:03:06","modified_gmt":"2020-03-19T09:03:06","slug":"%e4%bd%bf%e7%94%a8-php-%e5%95%9f%e5%8b%95-golang-binary-%e7%9a%84-directory-separator-%e5%95%8f%e9%a1%8c","status":"publish","type":"post","link":"https:\/\/imuslab.com\/wordpress\/2020\/03\/19\/%e4%bd%bf%e7%94%a8-php-%e5%95%9f%e5%8b%95-golang-binary-%e7%9a%84-directory-separator-%e5%95%8f%e9%a1%8c\/","title":{"rendered":"\u4f7f\u7528 PHP \u555f\u52d5 Golang Binary \u7684 DIRECTORY SEPARATOR \u554f\u984c"},"content":{"rendered":"\n<p>\u5728\u958b\u767c AOB \u7684\u6642\u5019\u4e0d\u77e5\u9053\u70ba\u5565 Windows \u958b\u767c\u7684 Websocket JWT \u767b\u5165\u7cfb\u7d71\u5728 Linux \u4e0a\u8dd1\u4e0d\u52d5\uff0c\u7136\u5f8c Golang \u5beb\u7684 WS Server  \u9084\u4e0d\u65b7\u5674 Error\uff0c\u4e00\u958b\u59cb\u9084\u4ee5\u70ba\u662f Golang \u7684\u554f\u984c\uff0c\u6700\u5f8c\u539f\u4f86\u662f\u555f\u52d5 Golang binary \u7684 PHP \u7684\u554f\u984c \u3002<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"738\" height=\"214\" src=\"http:\/\/124.244.86.40:8080\/wordpress\/wp-content\/uploads\/2020\/03\/2020-03-19_16-41-37.png\" alt=\"\" class=\"wp-image-444\" srcset=\"https:\/\/imuslab.com\/wordpress\/wp-content\/uploads\/2020\/03\/2020-03-19_16-41-37.png 738w, https:\/\/imuslab.com\/wordpress\/wp-content\/uploads\/2020\/03\/2020-03-19_16-41-37-300x87.png 300w\" sizes=\"auto, (max-width: 738px) 100vw, 738px\" \/><figcaption> Golang WebSocket Server \u5728 parse PHP \u8f38\u51fa\u7684 JSON \u6642\u51fa\u73fe\u4e86 &#8220;&lt;&#8221; \u7121\u6cd5\u89e3\u91cb\u6240\u4ee5 panic \u4e86 <\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"186\" src=\"http:\/\/124.244.86.40:8080\/wordpress\/wp-content\/uploads\/2020\/03\/2020-03-19_16-41-41-1024x186.png\" alt=\"\" class=\"wp-image-445\" srcset=\"https:\/\/imuslab.com\/wordpress\/wp-content\/uploads\/2020\/03\/2020-03-19_16-41-41-1024x186.png 1024w, https:\/\/imuslab.com\/wordpress\/wp-content\/uploads\/2020\/03\/2020-03-19_16-41-41-300x54.png 300w, https:\/\/imuslab.com\/wordpress\/wp-content\/uploads\/2020\/03\/2020-03-19_16-41-41-768x139.png 768w, https:\/\/imuslab.com\/wordpress\/wp-content\/uploads\/2020\/03\/2020-03-19_16-41-41-1200x218.png 1200w, https:\/\/imuslab.com\/wordpress\/wp-content\/uploads\/2020\/03\/2020-03-19_16-41-41.png 1368w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption> \u5728 Windows \u4e0a\u53d6\u5f97\u7531 Web Root \u5230 Authentication Service Script \u4f4d\u7f6e\u7684\u4ee3\u78bc\uff0cLinux \u4e0a\u6703\u56de\u50b3 &#8220;&#8221; \uff08Empty String\uff09\uff0c\u5fc5\u9808\u79fb\u9664\u6709\u95dc \/ \u8ddf \\ \u7684\u8655\u7406\u90e8\u5206\u624d\u80fd\u4f7f\u7528\u3002 <\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/Parse the launch paramters\nif (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {\n    \/\/Windows. Parse the launching path for validation services from wamp service webroot\n    $fullPath = str_replace($_SERVER&#91;'DOCUMENT_ROOT'],\"\",realpath(str_replace(\"\\\\\",\"\/\",__DIR__) . \"..\/..\/jwt\/validate.php\"));\n    $fullPath = str_replace(\"\\\\\",\"\/\",$fullPath);\n    $launchpath = str_replace($_SERVER&#91;'DOCUMENT_ROOT'] . \"\/\",\"\",$fullPath);\n}else{\n    \/\/Life is always simplier on Linux\n    $launchpath = str_replace($_SERVER&#91;'DOCUMENT_ROOT'] . \"\/\",\"\",realpath(\"..\/jwt\/validate.php\"));\n}<\/code><\/pre>\n\n\n\n<p>  \u9019\u554f\u984c\u4e3b\u8981\u51fa\u5728 PHP \u53ef\u4ee5\u628a \/ \u8ddf \\ \u540c\u6642\u7576\u4f5c &#8220;\/&#8221; \uff0c\u6240\u4ee5\u5728\u7a0b\u5f0f\u88e1\u4f5c\u70ba Directory Separator \u7528 &#8220;\/&#8221;  \u5c31\u597d\uff0c\u4e0d\u9700\u8981\u7279\u5225\u8655\u7406\uff0c\u4f46\u662f\u5728 Golang \u88e1 &#8220;\/&#8221; \u8ddf &#8220;\\&#8221; \u662f\u4e0d\u540c\u7684\u7b26\u865f\uff0c\u5fc5\u9808\u8981\u5148\u505a\u597d\u9810\u8655\u7406\u518d feed in \u5230\u88e1\u9762\u3002<\/p>\n\n\n\n<p> \uff08\u4f60\u554f\u6211\u70ba\u5565\u4e0d\u7528 DIRECTORY_SEPARATOR \uff1f\u56e0\u70ba\u6e2c\u8a66\u904e\u9019\u6771\u897f\u4e5f\u4e0d\u80fd\u7528\u554a\uff1f\u7279\u5225\u662f\u8981\u7d93\u904e realpath() \u7684\u6642\u5019\u7279\u5225\u5bb9\u6613\u51fa\u932f\uff09 <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u958b\u767c AOB \u7684\u6642\u5019\u4e0d\u77e5\u9053\u70ba\u5565 Windows \u958b\u767c\u7684 Websocket JWT \u767b\u5165\u7cfb\u7d71\u5728 Linux \u4e0a\u8dd1\u4e0d\u52d5\uff0c\u7136\u5f8c Golang \u5beb\u7684 WS Server \u9084\u4e0d\u65b7\u5674 Error\uff0c\u4e00\u958b\u59cb\u9084\u4ee5\u70ba\u662f Golang \u7684\u554f\u984c\uff0c\u6700\u5f8c\u539f\u4f86\u662f\u555f\u52d5 Golang binary \u7684 PHP \u7684\u554f\u984c \u3002 \u9019\u554f\u984c\u4e3b\u8981\u51fa\u5728 PHP \u53ef\u4ee5\u628a \/ \u8ddf \\ \u540c\u6642\u7576\u4f5c &#8220;\/&#8221; \uff0c\u6240\u4ee5\u5728\u7a0b\u5f0f\u88e1\u4f5c\u70ba Directory Separator \u7528 &#8220;\/&#8221; \u5c31\u597d\uff0c\u4e0d\u9700\u8981\u7279\u5225\u8655\u7406\uff0c\u4f46\u662f\u5728 Golang \u88e1 &#8220;\/&#8221; \u8ddf &#8220;\\&#8221; \u662f\u4e0d\u540c\u7684\u7b26\u865f\uff0c\u5fc5\u9808\u8981\u5148\u505a\u597d\u9810\u8655\u7406\u518d feed in \u5230\u88e1\u9762\u3002 \uff08\u4f60\u554f\u6211\u70ba\u5565\u4e0d\u7528 DIRECTORY_SEPARATOR \uff1f\u56e0\u70ba\u6e2c\u8a66\u904e\u9019\u6771\u897f\u4e5f\u4e0d\u80fd\u7528\u554a\uff1f\u7279\u5225\u662f\u8981\u7d93\u904e realpath() \u7684\u6642\u5019\u7279\u5225\u5bb9\u6613\u51fa\u932f\uff09<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-443","post","type-post","status-publish","format-standard","hentry","category-instructions-and-information"],"_links":{"self":[{"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/posts\/443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/comments?post=443"}],"version-history":[{"count":1,"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/posts\/443\/revisions"}],"predecessor-version":[{"id":446,"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/posts\/443\/revisions\/446"}],"wp:attachment":[{"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/media?parent=443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/categories?post=443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/tags?post=443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}