繁体   English   中英

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 ,在localhost 3000中,节点将其作为纯文本读取。如何将我登录的值传递到我的节点应用程序中。

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”。 之后您可以使用关键字执行任何操作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM