PHP 变量为 node.js
PHP variable to node.js
我使用 php 管理我的网页,我想在登录后立即将 PHP 变量传递到我的 index.ejs
文件。
<textarea id="inputText" class="base--textarea input--text-area" placeholder="Please enter text to analyze...">
<?php
session_start();
echo $_SESSION['description'];
?>
</textarea>
现在,当我 运行 nodejs app.js
,在本地主机 3000 中,node 将其读取为普通 text.How 我可以将我登录的值传递到我的 node 应用程序中吗?
app.get('/search.html', function(req, res) {
// Process the request for the GET variables
var url_parts = url.parse(req.url, true);
var query = url_parts.query; // These are all your GET variables
var search_keyword = query.keyword;
if(search_keyword) {
// The keyword indeed exists
console.log(search_keyword);
}
res.end();
});
这是我的做法:
创建一个新的 ExpressJS 应用
如果您 运行 应用程序并转到 "search.html?keyword=haha",您的控制台将输出 "haha"。之后您可以使用关键字执行任何操作。
我使用 php 管理我的网页,我想在登录后立即将 PHP 变量传递到我的 index.ejs
文件。
<textarea id="inputText" class="base--textarea input--text-area" placeholder="Please enter text to analyze...">
<?php
session_start();
echo $_SESSION['description'];
?>
</textarea>
现在,当我 运行 nodejs app.js
,在本地主机 3000 中,node 将其读取为普通 text.How 我可以将我登录的值传递到我的 node 应用程序中吗?
app.get('/search.html', function(req, res) {
// Process the request for the GET variables
var url_parts = url.parse(req.url, true);
var query = url_parts.query; // These are all your GET variables
var search_keyword = query.keyword;
if(search_keyword) {
// The keyword indeed exists
console.log(search_keyword);
}
res.end();
});
这是我的做法:
创建一个新的 ExpressJS 应用 如果您 运行 应用程序并转到 "search.html?keyword=haha",您的控制台将输出 "haha"。之后您可以使用关键字执行任何操作。