我在跑
$data = socket_read($socket, 2048, PHP_BINARY_READ);
Run Code Online (Sandbox Code Playgroud)
应该返回这样的字符串
// $data == ' 1840 kg G 008765 A '
Run Code Online (Sandbox Code Playgroud)
但它返回
Original response: HTTP/1.1 200 OK
Date: Wed, 19 Feb 2003 09:00:00 GMT
Server: MoxaHttp/1.0
Pragma: no-cache
Cache-Control: no-cache
Content-type: text/html
Content-length: 450
Run Code Online (Sandbox Code Playgroud)
这看起来像返回的数据的标题.
socket_send配置正确,我们有其他客户端具有相同的设置,并返回正确的值.
你能说出问题是什么,为什么我没有得到预期的字符串?
更新:
我多次重复socket_read()来读取它的完整字符串:
Original response: HTTP/1.1 200 OK
Date: Wed, 19 Feb 2003 09:00:00 GMT
Server: MoxaHttp/1.0
Pragma: no-cache
Cache-Control: no-cache
Content-type: text/html
Content-length: 450
Set-Cookie: ChallID=1656
<HTML><HEAD><TITLE>NPort Web Console</TITLE></HEAD> <FRAMESET rows=57,1* frameborder=NO> <FRAME name=top scrolling=NO target=contents src=top.htm …Run Code Online (Sandbox Code Playgroud) 我有大的DB功能,有这样的多行
RAISE NOTICE 'some step completed';
Run Code Online (Sandbox Code Playgroud)
我希望在我的PHP应用程序中获得所有这些通知.我发现只有pg_last_notice()返回最后通知的函数.
有什么方法可以得到所有通知吗?
示例:DB功能:
CREATE OR REPLACE FUNCTION do_smth()
RETURNS void AS
$BODY$
BEGIN
-- some actions
RAISE NOTICE 'Result of the actions:...';
-- some other actions
RAISE NOTICE 'Result of the other actions..';
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
Run Code Online (Sandbox Code Playgroud)
PHP代码:
<?php
// ...
$db->exec("SELECT do_smth()"); // executing DB function
$last_notice = pg_last_notice($db_connection);
// returns 'NOTICE: Result of the other actions..'
Run Code Online (Sandbox Code Playgroud) 我有一个包含id、date和 的表amount,我需要获取id按日期 DESC 排序的列表,该列表的总数大于或等于某个特定值。
id | date | amount
----|----------|--------
1 | 1/1/2017 | 3
2 | 2/1/2017 | 5
3 | 3/1/2017 | 4
4 | 4/1/2017 | 2
5 | 5/1/2017 | 7
6 | 6/1/2017 | 4
Run Code Online (Sandbox Code Playgroud)
例如
请帮助我找出循环期间本地"j"变量继续变化的原因:
var a1 = a2 = a3 = {};
for (var i = 1; i < 4; i ++ ) {
(function(j){
console.log(j);
window['a'+j].fu = function(){
console.log('fu:',j);
};
})(i);
}
a1.fu(); // returns "fu:,3" - why not 1?
a2.fu(); // returns "fu:,3" - why not 2?
a3.fu(); // returns "fu:,3"
Run Code Online (Sandbox Code Playgroud)
我在类似的问题上阅读了很好的答案,但这不符合我的情况.可以通过闭包访问可变变量.我怎样才能解决这个问题?