scp <file> <username>@<IP address or hostname>:<Destination>
The -r (recursive) option means to copy the whole folder and any sub-folders. You can also copy files the other way:
scp -r <file> OR <Folder> @IP address :<Destination>
scp file.txt remote_username@10.10.0.2:/remote/directory
The scp command syntax take the following form:
scp [OPTION] [user@]SRC_HOST:]file1 [user@]DEST_HOST:]file2
OPTION - scp options such as cipher, ssh configuration, ssh port, limit, recursive copy …etc.
[user@]SRC_HOST:]file1
- Source file.
[user@]DEST_HOST:]file2
- Destination file
scp provides a number of options that control every aspect of its behavior. The most widely used options are:
-P
- Specifies the remote host ssh port.
-p
- Preserves files modification and access times.
-q
- Use this option if you want to suppress the progress meter and non-error messages.
-C
- This option forces scp to compresses the data as it is sent to the destination machine.
-r
- This option tells scp to copy directories recursively.<?php
$a=array("red","green","blue","yellow","brown");
print_r(array_slice($a,2));
?>
$str = " Hello World! ";
echo "Without trim: " . $str;
echo "<br>";
echo "With trim: " . trim($str);
The HTML output of the code above will be (View Source):
<!DOCTYPE html>
<html>
<body>
Without trim: Hello World!
With trim: Hello World!
</body>
</html>
The browser output of the code above will be:Without trim: Hello World!
With trim: Hello World!
echo substr("Hello world",6);
Using the start parameter with different positive and negative numbers:
// Positive numbers:
echo substr("Hello world",10)."<br>"; //d
echo substr("Hello world",1)."<br>"; //ello world
echo substr("Hello world",3)."<br>"; //lo world
echo substr("Hello world",7)."<br>"; //orld
echo "<br>";
// Negative numbers:
echo substr("Hello world",-1)."<br>"; //d
echo substr("Hello world",-10)."<br>"; //ello world
echo substr("Hello world",-8)."<br>"; //lo world
echo substr("Hello world",-4)."<br>"; //orld
Using the start and length parameters with different positive and negative numbers:
// Positive numbers:
echo substr("Hello world",0,10)."<br>"; //Hello worl
echo substr("Hello world",1,8)."<br>"; //ello wor
echo substr("Hello world",0,5)."<br>"; //Hello
echo substr("Hello world",6,6)."<br>"; //world
echo "<br>";
// Negative numbers:
echo substr("Hello world",0,-1)."<br>"; //Hello worl
echo substr("Hello world",-10,-2)."<br>"; //ello wor
echo substr("Hello world",0,-6)."<br>"; //Hello
// Interesting example about if-elseif-else statement
$test = "STRING, NOT INTEGER OR FLOAT";
if ($test < 12) {
echo "child";
} else if ($test > 12 && $test < 18 ) {
echo "teen";
} else {
echo "adult";
}
// what do you think, what will be output, error or ?
// make that example on your PC if you are a begginer :)
for (init counter; test counter; increment counter) {
code to be executed for each iteration;
}
The PHP while Loop
The while loop executes a block of code as long as the specified condition is true.
Syntax
while (condition is true) {
code to be executed;
}
`