Php 如何在两个$\u POST函数之间插入空格
我有以下代码:Php 如何在两个$\u POST函数之间插入空格,php,textbox,space,Php,Textbox,Space,我有以下代码: <html> <head> <title>Write to a text file</title> </head> <body> Add your text <form action="" method='post'> <input name='textblock'></input> <input name='otherblock'></input>
<html>
<head>
<title>Write to a text file</title>
</head>
<body>
Add your text
<form action="" method='post'>
<input name='textblock'></input>
<input name='otherblock'></input>
<input type='submit' value='Add text'>
</form>
<?php
// Open the text file
$f = fopen("texties.txt", "a");
// Write text
fwrite($f, $_POST["textblock"] . $_POST["otherblock"] . "\r\n");
// Close the text file
fclose($f);
$filecontents = file_get_contents("texties.txt");
print nl2br($filecontents);
?>
</body>
</html>
写入文本文件
添加文本
它生成用户在文本框中输入的任何内容,例如“蓝色”和“水牛”作为
蓝飞碟
我怎样才能把它读出来
蓝水牛
谢谢大家! 这可以做到:
fwrite($f, $_POST["textblock"]." ". $_POST["otherblock"] . "\r\n");
当你看到这一点时,你会踢自己,但很简单:
<html>
<head>
<title>Write to a text file</title>
</head>
<body>
Add your text
<form action="" method='post'>
<input name='textblock'></input>
<input name='otherblock'></input>
<input type='submit' value='Add text'>
</form>
<?php
// Open the text file
$f = fopen("texties.txt", "a");
// Write text
fwrite($f, $_POST["textblock"] . " " . $_POST["otherblock"] . "\r\n");
// Close the text file
fclose($f);
$filecontents = file_get_contents("texties.txt");
print nl2br($filecontents);
?>
</body>
</html>
写入文本文件
添加文本
你知道什么是。“\r\n”
是吗?只要在两个变量之间加上一个空格就行了。