我想将用户名发布到PHP文件。然后我希望用户名将在PHP文件中实现,我将在我的脚本中编写。
但它不起作用?我如何在$ Line 5的字符串中实现POST用户名?而且我想把每一行都写成单行,我想把它放在一起。我猜是复制文件会更容易,并在那里实现Post但我不知道该怎么做。
Token Infos不是真正的;)
$username = $_POST["username"];
//twilio tokenlines
$Line0 = "<?php";
$Line1 = "include '../Services/Twilio/Capability.php'";
$Line2 = "$accountSid = '3763876534876584'; ";
$Line3 = "$authToken = '4765784365874365'; ";
$Line4 = "$capability = new Services_Twilio_Capability($accountSid, $authToken); ";
$Line5 = "$capability->allowClientIncoming("HERE I WANT TO STAND MY POST"); ";
$Line6 = "$capability->allowClientOutgoing('746357846358764387564387'); ";
$Line7 = "$token = $capability->generateToken(); ";
$Line8 = "echo $token;";
$Line9 = "?>";
$tokenfile = fopen("${username}.php", 'w');
fwrite($tokenfile,$Line0);
fwrite($tokenfile,$Line1);
fwrite($tokenfile,$Line2);
fwrite($tokenfile,$Line3);
fwrite($tokenfile,$Line4);
fwrite($tokenfile,$Line5);
fwrite($tokenfile,$Line6);
fwrite($tokenfile,$Line7);
fwrite($tokenfile,$Line8);
fwrite($tokenfile,$Line9);
答案 0 :(得分:1)
只需在每个字符串的末尾附加\n
即可创建多行。
$Line0 = "<?php\n";
别忘了打电话
fclose($tokenfile)
- 只有这样才能保证内容写入磁盘。
答案 1 :(得分:1)
<强>分号强>
$Line1 = "include '../Services/Twilio/Capability.php'";
=&GT;
$Line1 = "include '../Services/Twilio/Capability.php'; ";
^
<强>逃逸强>
$Line5 = "$capability->allowClientIncoming("HERE I WANT TO STAND MY POST"); ";
=&GT;
$Line5 = "$capability->allowClientIncoming(\"HERE I WANT TO STAND MY POST\"); ";
^ ^
将 PHP_EOL
添加到每行的末尾。
$Line1 = '...'.PHP_EOL;
$Line2 = '...'.PHP_EOL;
...
还将所有"
转换为'
因为它翻译了$ abc而我们不想要它。