[英]PHP ssh2_scp_send file permissions
I am using the PHP function ssh2_scp_send
to transfer files from one server to another. 我使用PHP函数ssh2_scp_send
将文件从一个服务器传输到另一个服务器。 The interesting things is that if I write the permission in it's octal form (ie 0644) directly everything works fine. 有趣的是,如果我以八进制形式(即0644)直接写入权限,一切正常。 If I instead enclose this in inverted commas or use a variabel this does not work any more. 如果我用倒置的逗号括起来或使用变量,这不再起作用了。
To be clearer: This works: ssh2_scp_send($conn, $localFile, $remoteFile, 0644);
更清楚:这是有效的: ssh2_scp_send($conn, $localFile, $remoteFile, 0644);
Does NOT work: ssh2_scp_send($conn, $localFile, $remoteFile, "0644");
不起作用: ssh2_scp_send($conn, $localFile, $remoteFile, "0644");
Does NOT work: $permission=0644;ssh2_scp_send($conn, $localFile, $remoteFile, $permission);
不起作用: $permission=0644;ssh2_scp_send($conn, $localFile, $remoteFile, $permission);
Anybody has any idea why this is the case? 任何人都知道为什么会这样吗?
The string may be interpreted as decimal. 该字符串可以解释为十进制。
Also, what type is $permission
? 另外, $permission
是什么类型的? Try using var_dump()
on it. 尝试使用var_dump()
。 It may be a string too. 它也可能是一个字符串。
$a = 0644;
$b = (int) "0644";
var_dump($a, $b); // int(420), int(644)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.