I
I
Ilya Trusov2016-02-22 14:27:27
PHP
Ilya Trusov, 2016-02-22 14:27:27

How to remove the line break character?

Hello.
I do:

$command_script = "create_first_file.sh $this->server_user_name $id_app index$type_ex_file";
ssh2_exec($connection, "echo pass | sudo -S /bin/bash /opt/scripts/$command_script")

create_first_file.sh
#!/bin/bash

#Create file
mkdir /opt/jails/$1/home/$1/$2
chown $1:$1 /opt/jails/$1/home/$1/$2
touch /opt/jails/$1/home/$1/$2/$3
chown $1:$1 /opt/jails/$1/home/$1/$2/$3

But when creating a folder with $id_app at the end of the name, a line break, although it is just a number. It's worth mentioning that $id_app is passed from the form.
<input id="id_app" name="id_app" value="<?= $data->id; ?>" hidden>

I don't understand where this transfer could come from.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Nemiro, 2016-02-22
@AlekseyNemiro

Pass through trim .

$command_script = "create_first_file.sh $this->server_user_name " .
                  trim($id_app) . " index$type_ex_file";

It's hard to say where the extra line feed comes from. I need to watch it live :-) I don't remember such behavior with forms in PHP . Maybe the problem is in the incoming data ( $data->id). By the way, the semicolon is superfluous there, enough: <?=$data->id?>.
Or does the data change somewhere between being sent and passed to $id_app.
You can set breakpoints and see what happens.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question