php://input在localhost中正常工作.但在服务器中它返回空.输入(请求)到我的站点是一个json(REST - 应用程序/ json类型),所以$_POST没有工作(请阅读此问题).
$ _POST与键值对类型输入一起使用,例如form-data或x-www-urlencoded
键1 =值&键2 =值&KEY3 = VALUE3
我正在使用application/json输入(在REST中).
就像{'key1':'value1','key2':'value2','key3':'value3'}
这无法使用$_POST.但使用php://input可以帮助读取该数据.
我的代码
class Webservice_Controller extends CI_Controller {
public $json_input_data;
public function __construct(){
parent::__construct();
$this->json_input_data = json_decode(file_get_contents('php://input'),TRUE);
}
public function json_input($label){
if(isset($this->json_input_data[$label])) return $this->json_input_data[$label];
else return NULL;
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码在另一个网络服务器上工作正常,但不是在当前的.:(
我认为我的网络服务器拒绝访问php://input.
是否还有其他方法可以在php中读取json输入?
我想如何阅读在我的办公桌上的文件顶部使用pg_read_file在 PostgreSQL的
pg_read_file(文件名文本[,偏移bigint,长度bigint])
我的查询
select pg_read_file('/root/desktop/new.txt' , 0 , 1000000);
Run Code Online (Sandbox Code Playgroud)
错误
ERROR: absolute path not allowed
Run Code Online (Sandbox Code Playgroud)
我想在 PostgreSQL 中使用 lo_import 读取桌面中的文件
如何使用此功能将内容插入表格并稍后显示
SELECT lo_import('/root/desktop/new.txt');
Run Code Online (Sandbox Code Playgroud)
输出
18767
Run Code Online (Sandbox Code Playgroud) 我想检查给定字符串中多个字符串的可用性(不使用循环).
喜欢
my_string = "How to find occurence of multiple sting in a given string using javascript RegExp";
// search operated on this string
// having a-z (lower case) , '_' , 0-9 , and space
// following are the strings wanted to search .( having a-z , 0-9 , and '_')
search_str[0]="How";
search_str[1]="javascript";
search_str[2]="sting";
search_str[3]="multiple";
Run Code Online (Sandbox Code Playgroud)
是否有可用于此的正则表达式?
更新:我错过了什么
在答案中,我发现这一个正在解决上述问题
if (/^(?=.*\bHow\b)(?=.*\bjavascript\b)(?=.*\bsting\b)(?=.*\bmultiple\b)/.test(subject)) {
// Successful match
}
Run Code Online (Sandbox Code Playgroud)
但在这种情况下,它无法正常工作.
m_str="_3_5_1_13_10_11_";
search_str[0]='3';
search_str[1]='1';
tst=new RegExp("^(?=.*\\b_"+search_str[0]+"_\\b)(?=.*\\b_"+search_str[1]+"_\\b)");
if(tst.test(m_str)) …Run Code Online (Sandbox Code Playgroud) database ×2
postgresql ×2
codeigniter ×1
javascript ×1
jquery ×1
json ×1
php ×1
regex ×1
rest ×1
sql ×1