PHP Sem 1 - 2
PHP Sem 1 - 2
2) Operators in PHP
Roll No-
What is PHP
PHP was created by Rasmus Lerdorf in 1994 but appeared in the market in 1995. PHP 7.4.0
is the latest version of PHP, which was released on 28 November. Some important points
need to be noticed about PHP are as followed:
PHP is faster than other scripting languages, for example, ASP and JSP.
PHP is a server-side scripting language, which is used to manage the dynamic content of the
website.
PHP is a server-side scripting language, which is used to design the dynamic web
applications with MySQL database.
It handles dynamic content, database as well as session tracking for the website.
Using PHP language, you can control the user to access some pages of your website.
As PHP is easy to install and set up, this is the main reason why PHP is the best language to
learn.
PHP can handle the forms, such as - collect the data from users using forms, save it into the
database, and return useful information to the user. For example - Registration form.
PHP Features
PHP is very popular language because of its simplicity and open source. There are some
important features of PHP given below:
Performance:
PHP script is executed much faster than those scripts which are written in other languages
such as JSP and ASP. PHP uses its own memory, so the server workload and loading time is
automatically reduced, which results in faster processing speed and better performance.
Open Source:
PHP source code and software are freely available on the web. You can develop all the
versions of PHP according to your requirement without paying any cost. All its components
are free to download and use.
PHP has easily understandable syntax. Programmers are comfortable coding with it.
Embedded:
PHP code can be easily embedded within HTML tags and script.
Platform Independent:
PHP is available for WINDOWS, MAC, LINUX & UNIX operating system. A PHP application
developed in one OS can be easily executed in other OS also.
Database Support:
PHP supports all the leading databases such as MySQL, SQLite, ODBC, etc.
Error Reporting -
PHP has predefined error reporting constants to generate an error notice or warning at
runtime. E.g., E_ERROR, E_WARNING, E_STRICT, E_PARSE.
Loosely Typed Language:
PHP allows us to use a variable without declaring its datatype. It will be taken automatically
at the time of execution based on the type of data it contains on its value.
PHP is compatible with almost all local servers used today like Apache, Netscape, Microsoft
IIS, etc.
Security:
PHP is a secure language to develop the website. It consists of multiple layers of security to
prevent threads and malicious attacks.
Control:
Different programming languages require long script or code, whereas PHP can do the same
work in a few lines of code. It has maximum control over the websites like you can make
changes easily whenever you want.
Web Development
PHP is widely used in web development nowadays. PHP can develop dynamic websites
easily. But you must have the basic the knowledge of following technologies for web
development as well.
o HTML
o CSS
o JavaScript
o Ajax
o jQuery
Install PHP
To install PHP, we will suggest you to install AMP (Apache, MySQL, PHP) software stack. It is
available for all operating systems. There are many AMP options available in the market that
are given below:
WAMP for Windows
XAMPP (Cross, Apache, MySQL, PHP, Perl) for Cross Platform: It includes some other
components too such as FileZilla, OpenSSL, Webalizer, Mercury Mail, etc.
If you are on Windows and don't want Perl and other features of XAMPP, you should go for
WAMP. In a similar way, you may use LAMP for Linux and MAMP for Macintosh.
new project without changing the current local server settings. so i am trying to cover the
changing the version by keeping the old version manually.
Now i am going to show how you will overcome this situation. my present php version is php-
5.6.36
Step 1: First download the latest php version from http://windows.php.net/download#php-
7.0 Download the VC14 x86 Thread Safe or VC14 x64 Thread Safe deciding upon your
Windows version( x86 for 32-bit and x64 for 64-bit ). Next extract the zip file in a folder
named php.
Step 2: Go to your XAMPP installation directory and rename your old php directory with old
version prefix like php to php_5_6_36. Now copy & paste the extracted new php folder to
here.
On PHP-Module setup section, comment these two lines and add the two lines below
# PHP-Module setup
#LoadFile “D:/xampp/php/php5ts.dll”
That’s it. Now restart your XAMPP server and keep coding.
Run multiple version of PHP in XAMPP Windows (Without installing multiple XAMPP)
Why switch between PHP versions when you can use multiple PHP version at a same time
with a single xampp installation? With a single xampp installation, you have 2 options:
1. Run an older PHP version for only the directory of your old project: This will serve the
purpose most of the time, you may have one or two old projects that you intend to run
with older PHP version. Just configure xampp to run older PHP version only for those
project directories.
2. Run an older PHP version on a separate port of xampp: Sometimes you may be
upgrading and old project to latest PHP version when you need to run the same project
on new and older php version back and forth. Then you can set an older PHP version on a
different port (say 8056) so when you go to http://localhost/any_project/ xampp runs
php 7 and when you go to http://localhost:8056/any_project/ xampp runs php 5.6.
Lets set it up.
<Directory "C:\xampp\htdocs\my_old_project1">
UnsetEnv PHPRC
<FilesMatch "\.php$">
SetHandler application/x-httpd-php56
Action application/x-httpd-php56 "/php56/php-cgi.exe"
</FilesMatch>
</Directory>
<Directory "C:\xampp\htdocs\my_old_project2">
UnsetEnv PHPRC
<FilesMatch "\.php$">
SetHandler application/x-httpd-php56
Action application/x-httpd-php56 "/php56/php-cgi.exe"
</FilesMatch>
</Directory>
Step 4 (option 2): [Run older PHP version on a separate port]
Now to to set PHP v5.6 to port 8056 add the following code to the bottom of the config file.
Listen 8056
<VirtualHost *:8056>
UnsetEnv PHPRC
<FilesMatch "\.php$">
php_flag engine off
SetHandler application/x-httpd-php56
Action application/x-httpd-php56 "/php56/php-cgi.exe"
</FilesMatch>
</VirtualHost>
Finish: Save and Restart Apache
Save and close the config file, Restart apache from xampp control panel. If you went for
option 2 you can see the additional port(8056) listed in your xampp control panel.
I suggest you read the official PHP documentation about installing it on Windows systems.
Download the latest PHP binaries from the official PHP for Windows download page, choose
the thread-safe version that matches your Apache installation's bit-version (x86 for 32-Bit,
x64 for 64-Bit).
The non thread-safe version is only when running as a CGI binary - more info here.
The version I used is this : PHP 5.6.2 VC11 x64 Thread Safe. The latest version when this
answer was last updated: PHP 7.3.3 VC15 x64 Thread Safe (look at the edit date at the
bottom of the post).
Create an empty PHP folder at the root of your hard drive, and extract the previously
downloaded archive there, you should have a path like C:\PHP\ext, otherwise you did
something wrong.
In C:\PHP, rename the php.ini-production or php.ini-development (depending on what you
want) to php.ini.
Open that php.ini file, search for extension_dir = "ext" and uncomment that line (remove
the first ;). This sets the default extension dir to ext (which resolves to C:\PHP\ext and
avoids having to prepend ext/ to all extension's paths manually like in previous versions of
this post.
Now configure Apache to use that PHP, by editing C:\Apache24\conf\httpd.conf - after all
the LoadModule lines, add the following :
(The follow is for PHP 7 only)
LoadModule php7_module "c:\php\php7apache2_4.dll"
<IfModule php7_module>
<IfModule php5_module>
DirectoryIndex index.html index.php
AddHandler application/x-httpd-php .php
PHPIniDir "C:/PHP"
</IfModule>
Now try to start Apache manually by opening a command prompt in C:\Apache24\bin and
running httpd.exe - if you see no errors, it means your configuration file is valid and PHP
is most likely working.
You can test your PHP installation by creating a file like info.php with <?php phpinfo(); inside
and going to http://localhost/info.php - you should see quite a bit of info about your system
and your PHP installation and all its modules. If you get something else like an "Internal
server error" that means something's wrong.
You can now kill your current Apache process (Ctrl+C in the console) and start the service -
the following part doesn't interact with Apache and can be done with the server already
started.
Composer - optional
Composer is a tool for dependency management in PHP, like a package manager. It allows to
easily install PHP packages and even entire frameworks.
WhatisthePHP/JavaBridge?
PHP Syntax
A PHP file normally contains HTML tags, and some PHP scripting code.
Below, we have an example of a simple PHP file, with a PHP script that uses a built-in PHP
function "echo" to output the text "Hello World!" on a web page:
Example
<!DOCTYPE html>
<html>
<body>
<?php
echo "Hello World!";
?>
</body>
</html>
Out put
Hello World!
PHP Variables
Example
<?php
$txt = "Hello world!";
$x = 5;
$y = 10.5;
?>
A variable starts with the $ sign, followed by the name of the variable
A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9,
and _ )
Variable names are case-sensitive ($age and $AGE are two different variables)
PHP Constants
A constant is an identifier (name) for a simple value. The value cannot be changed during
the script.
A valid constant name starts with a letter or underscore (no $ sign before the constant
name).
Note: Unlike variables, constants are automatically global across the entire script.
Syntax
Parameters:
<?php
echo greeting;
?>
Out put
Welcome to PHP!
Assignment No- 2
Roll No-
What is Operator? Simple answer can be given using expression 4 + 5 is equal to 9. Here 4
and 5 are called operands and + is called operator. PHP language supports following type of
operators.
Arithmetic Operators
Comparison Operators
Logical (or Relational) Operators
Assignment Operators
Conditional (or ternary) Operators
Lets have a look on all operators one by one.
Arithmetic Operators
Comparison Operators
== Checks if the value of two operands are equal or not, if yes then (A == B) is not
condition becomes true. true.
!= Checks if the value of two operands are equal or not, if values are not (A != B) is
equal then condition becomes true. true.
> Checks if the value of left operand is greater than the value of right (A > B) is not
operand, if yes then condition becomes true. true.
< Checks if the value of left operand is less than the value of right (A < B) is true.
operand, if yes then condition becomes true.
>= Checks if the value of left operand is greater than or equal to the value (A >= B) is not
of right operand, if yes then condition becomes true. true.
<= Checks if the value of left operand is less than or equal to the value of (A <= B) is
right operand, if yes then condition becomes true. true.
Logical Operators
or Called Logical OR Operator. If any of the two operands are non zero (A or B) is
then condition becomes true. true.
&& Called Logical AND operator. If both the operands are non zero then (A && B) is
condition becomes true. true.
|| Called Logical OR Operator. If any of the two operands are non zero (A || B) is
then condition becomes true. true.
! Called Logical NOT Operator. Use to reverses the logical state of its !(A && B) is
operand. If a condition is true then Logical NOT operator will make false.
false.
Assignment Operators
= Simple assignment operator, Assigns values from right side C = A + B will assign
operands to left side operand value of A + B into C
Conditional Operator
There is one more operator called conditional operator. This first evaluates an expression
for a true or false value and then execute one of the two given statements depending upon
the result of the evaluation. The conditional operator has this syntax −
Show Examples
Operators Categories
All the operators we have discussed above can be categorised into following categories −
Unary prefix operators, which precede a single operand.
Binary operators, which take two operands and perform a variety of arithmetic and
logical operations.
The conditional operator (a ternary operator), which takes three operands and
evaluates either the second or third expression, depending on the evaluation of the
first expression.
Assignment operators, which assign a value to a variable.
Operator precedence determines the grouping of terms in an expression. This affects how
an expression is evaluated. Certain operators have higher precedence than others; for
example, the multiplication operator has higher precedence than the addition operator −
For example x = 7 + 3 * 2; Here x is assigned 13, not 20 because operator * has higher
precedence than + so it first get multiplied with 3*2 and then adds into 7.
Here operators with the highest precedence appear at the top of the table, those with the
lowest appear at the bottom. Within an expression, higher precedence operators will be
evaluated first.
Category Operator Associativity
Roll No-
<?php
$num=12;
if($num%2==0){
}else{
?>
Output:
12 is even number
Assignment No- 4
Roll No-
<?php
$ch = 'U';
switch ($ch)
case 'a':
break;
case 'e':
break;
case 'i':
break;
case 'o':
break;
case 'u':
break;
case 'A':
echo "Given character is vowel";
break;
case 'E':
break;
case 'I':
break;
case 'O':
break;
case 'U':
break;
default:
break;
?>
Output:
Roll No-
<?php
//declare array
echo "$element";
echo "</br>";
?>
Out put
Summer
Winter
Autumn
Rainy
Assignment No- 6
Roll No-
<?php
$num = 14597;
$sum=0; $rem=0;
$rem=$num%10;
$num=$num/10;
?>
Output:
Assignment No- 7
Roll No-
<?php
$count = 0;
$num = 2;
$div_count=0;
if (($num%$i)==0)
$div_count++;
if ($div_count<3)
$count=$count+1;
$num=$num+1;
}
?>
Output:
Assignment No- 8
Roll No-
<?php
define('a', 7);
echo $i*a;
echo '<br>';
?>
Output:
Assignment No- 9
Roll No-
<?php
$num = 4;
$factorial = 1;
?>
Output:
Assignment No- 10
Roll No-
<?php
$num=407;
$total=0;
$x=$num;
while($x!=0)
{
$rem=$x%10;
$total=$total+$rem*$rem*$rem;
$x=$x/10;
}
if($num==$total)
{
echo "Yes it is an Armstrong number";
}
else
?>
Output:
Assignment No- 11
Roll No-
<?php
function palindrome($n){
$number = $n;
$sum = 0;
while(floor($number)) {
$number = $number/10;
}
return $sum;
}
$input = 1235321;
$num = palindrome($input);
if($input==$num){
} else {
?>
Output:
Assignment No- 12
Roll No-
<?php
$num = 0;
$n1 = 0;
$n2 = 1;
echo "\n";
$n1 = $n2;
$n2 = $n3;
$num = $num + 1;
?>
Output:
Semester II PHP
1) Arrays in PHP
2) Function in PHP
5) htmlspecialchars() function
Roll No-
PHP index is represented by number which starts from 0. We can store number, string and
object in the PHP array. All PHP array elements are assigned to an index number by default.
Example 1
<?php
$season=array("summer","winter","spring","autumn");
?>
Output:
Example 2
<?php
$season[0]="summer";
$season[1]="winter";
$season[2]="spring";
$season[3]="autumn";
?>
Output:
We can associate name with each array elements in PHP using => symbol.
Example 1
<?php
$salary=array("Sonoo"=>"350000","John"=>"450000","Kartik"=>"200000");
?>
Output:
Example 2
<?php
$salary["Sonoo"]="350000";
$salary["John"]="450000";
$salary["Kartik"]="200000";
?>
Output:
PHP multidimensional array is also known as array of arrays. It allows you to store tabular
data in an array. PHP multidimensional array can be represented in the form of matrix which
is represented by row * column.
Example
<?php
$emp = array
array(1,"sonoo",400000),
array(2,"john",500000),
array(3,"rahul",300000)
);
echo "<br/>";
?>
Output:
1 sonoo 400000
2 john 500000
3 rahul 300000
Example
<?php
$season=array("summer","winter","spring","autumn");
$reverseseason=array_reverse($season);
foreach( $reverseseason as $s )
?>
Output:
autumn
spring
winter
summer
<?php
if ($nr_elm > 0) {
// If the number of columns is completed for a row (rest of division of ($i + 1) to $nr_col is
0)
// Delete posible empty row (<tr></tr>) which cand be created after last column
?>
Output
https://coursesweb.net marplo.net
Courses Web
Programming
PHP-MySQL
Assignment No- 2
Roll No-
<?php
function sayHello(){
sayHello();//calling function
?>
Output:
<?php
function sayHello($name,$age){
sayHello("Sonoo",27);
sayHello("Vimal",29);
sayHello("John",23);
?>
Output:
<?php
function adder($str2)
adder($str);
echo $str;
?>
Output:
Hello
<?php
function adder(&$str2)
{
$str2 .= 'Call By Reference';
}
$str = 'This is ';
adder($str);
echo $str;
?>
Output:
<?php
function sayHello($name="Ram"){
sayHello("Sonoo");
sayHello();//passing no value
sayHello("Vimal");
?>
Output:
Hello Sonoo
Hello Ram
Hello Vimal
<!DOCTYPE html>
<html>
<body>
<?php
function add1() {
static $number = 0;
$number++;
return $number;
echo add1();
echo "<br>";
echo add1();
echo "<br>";
echo add1();
?>
</body>
</html>
Out put
<?php
$scores = array(10,20,30,40,50,90);
function average($array){
// set 'total' to 0
$total = 0;
foreach($array as $value){
$total += $value;
return $total/count($array);
}
// call the 'average' function and use the 'scores' array as argument
?>
Output
Avarage =40
<?php
function salestax($price,$tax) {
salestax(15.00,.075);
echo convert_pound(15);
?>
Out put
<?php
function display($number) {
if($number<=5){
echo "$number <br/>";
display($number+1);
display(1);
?>
Output:
<?php
$greet = function($name)
};
$greet('World');
$greet('PHP');
?>
Out put
<?php
function sayHello() {
print "hello<br>";
$function_holder = "sayHello";
$function_holder();
?>
Out put
Hello
Example 1
<html>
<body>
<?php
function my_callback($item) {
return strlen($item);
print_r($lengths);
?>
</body>
</html>
Out put
Array
(
[0] => 5
[1] => 6
[2] => 6
[3] => 7
)
Example 2
<?php
function exclaim($str) {
function ask($str) {
echo $format($str);
?>
Output
Callback Functions
Example 1
<?php
function my_callback($item) {
return strlen($item);
print_r($lengths);
?>
Out put
Array
(
[0] => 5
[1] => 6
[2] => 6
[3] => 7
)
Example 2
<?php
function exclaim($str) {
function ask($str) {
echo $format($str);
?>
Out put
Roll No-
Error: An Error is an unexpected program result, which can not be handled by the program
itself. That can be solved by using the issue in the code manually. An Error can be an infinite
loop that can not be handled by the program itself so you have to manually repair that
issue. There is an easy procedure to handle error i.e. using die() function.
Example
<?php
if (!file_exists("myfile.txt")) {
else {
fopen("myfile.txt", "r");
?>
Output:
<?php
if($y != 0) {
return true;
else {
try {
valid_division(2, 0);
// there is no exception
catch(Exception $e) {
// exception occurs
echo "Error\n";
echo $e->getmessage();
?>
Output:
Error
ERROR EXCEPTION
The default error handling in PHP is very Exceptions are used to change the normal
simple. An error message with filename, flow of a script if a specified error occurs.
line number and a message describing
the error is sent to the browser.
This can be done using PHP Basic Exception Handling using throw new
die() Function. Exception() in case of advance Exception
handling youn have to
use try and catch method.
Errors are mostly caused by the Program itself is responsible for causing
environment in which program is exceptions.
running.
<?php
function demo($var) {
try {
if($var == 0)
{
catch(Exception $e) {
demo(5);
demo(0);
?>
Output:
<?php
declare(strict_types=1);
return $a / $b;
$a=10;
$b=0;
try{
if (!$b) {
if (is_int($a)==FALSE || is_int($b)==FALSE)
$result=divide($a, $b);
echo $result;
echo $x->getMessage();
echo $y->getMessage();
}
catch (ArgumentCountError $z) //if no.of arguments not equal to 2{
echo $z->getMessage();
echo $i->getMessage();
echo $ex->getMessage();
?>
Output
Set $b=3 which will cause TypeError because divide function is expected to return integer
but dividion results in float
Return value of divide() must be of the type integer, float returned
If just one variable is passed to divide function by changing res=divide(a); this will result
ArgumentCountError
Too few arguments to function divide(), 1 passed in C:\xampp\php\test1.php on line 13 and
exactly 2 expected
<?php
class myException extends Exception{
function message(){
return "error : " . $this->getMessage() . " in line no " . $this->getLine();
}
}
$num=125;
try{
if ($num>100 || $num<0)
throw new myException("$num is invalid number");
else
echo "$num is a valid number";
}
catch (myException $m){
echo $m->message();
}
?>
Output
Run above code with num=125andnum=90 to get error message and message of valid
number
There are two ways the browser client can send information to the web server.
The GET method sends the encoded user information appended to the page request. The
page and the encoded information are separated by the ? character.
http://www.test.com/index.htm?name1=value1&name2=value2
The GET method produces a long string that appears in your server logs, in the
browser's Location: box.
The GET method is restricted to send upto 1024 characters only.
Never use GET method if you have password or other sensitive information to be
sent to the server.
GET can't be used to send binary data, like images or word documents, to the server.
The data sent by GET method can be accessed using QUERY_STRING environment
variable.
The PHP provides $_GET associative array to access all the sent information using
GET method.
exit();
}
?>
<html>
<body>
Output
exit();
}
?>
<html>
<body>
Output
Assignment No- 5
Roll No-
Example
<?php
$str = "This is some <b>bold</b> text.";
echo $str ;
echo "<br>";
echo htmlspecialchars($str);
?>
Out put
This is some bold text.
This is some <b>bold</b> text.
Assignment No- 6
Roll No-
Form1.html
<html>
<body>
</body>
</html>
Welcome.php
<html>
<body>
</body>
</html>
Out put
Welcome ram
Your email address is [email protected]
Assignment No- 7
Roll No-
<html>
<head>
</head>
<body>
<?php
// define variables and set to empty values
$name = $email = $gender = $comment = $website = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = test_input($_POST["name"]);
$email = test_input($_POST["email"]);
$website = test_input($_POST["website"]);
$comment = test_input($_POST["comment"]);
$gender = test_input($_POST["gender"]);
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<h2>PHP Form Validation Example</h2>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
Name: <input type="text" name="name">
<br><br>
E-mail: <input type="text" name="email">
<br><br>
Website: <input type="text" name="website">
<br><br>
Comment: <textarea name="comment" rows="5" cols="40"></textarea>
<br><br>
Gender:
<input type="radio" name="gender" value="female">Female
<input type="radio" name="gender" value="male">Male
<input type="radio" name="gender" value="other">Other
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
echo "<h2>Your Input:</h2>";
echo $name;
echo "<br>";
echo $email;
echo "<br>";
echo $website;
echo "<br>";
echo $comment;
echo "<br>";
echo $gender;
?>
</body>
</html>
Out put
PHP Form Validation Example
Name:
E-mail:
Website:
Comment:
Gender: Female Male Other
Submit
Your Input:
rupesh
[email protected]
google.com
like this website
male
Assignment No- 8
Roll No-
Multivalued.html
<html>
<body>
<form action="indexdemo.php" method="post">
<label for="firstName">First name</label>
<input type="text" name="firstName" id="firstName" value="" />
<label for="mySelection">What are your favorite widgets?</label>
<select name="mySelection[]" id="mySelection" size="3" multiple="multiple">
<option value="PHP">PHP Language</option>
<option value="Java">Java Language</option>
<option value="CSS">CSS Language</option>
</select>
<label for="tested">Choice One?</label>
<input type="checkbox" name="chioces[]" id="ChoiceOne" value="testTask" />
<label for="designed">Choice Two?</label>
<input type="checkbox" name="chioces[]" id="ChoiceTwo" value="designTask" />
<input type="submit" name="submitButton" id="submitButton" value="Send Details"
/>
<input type="reset" name="resetButton" id="resetButton" value="Reset Form"/>
</div>
</form>
</body>
</html>
indexdemo.php
<html>
<body>
<?php
$mySelection = "";
$chiocess = "";
if ( isset( $_POST["mySelection"] ) ) {
foreach ( $_POST["mySelection"] as $widget ) {
$mySelection .= $widget . ", ";
}
}
if ( isset( $_POST["chioces"] ) ) {
foreach ( $_POST["chioces"] as $chioces ) {
$chiocess .= $chioces . ", ";
}
}
$mySelection = preg_replace( "/, $/", "", $mySelection );
$chiocess = preg_replace( "/, $/", "", $chiocess );
?><dl>
<dt>First name</dt><dd><?php echo $_POST["firstName"]?></dd>
<dt>Favorite widgets</dt><dd><?php echo $mySelection?></dd>
<dt>You want to receive the following chiocess:</dt><dd>
<?php echo $chiocess?></dd>
</dl>
</body>
</html>
Out put
Rupesh
First name
PHP Language
Java Language
What are your favorite widgets? CSS Language
First name
Rupesh
Favorite widgets
PHP, Java, CSS
You want to receive the following chiocess:
testTask, designTask
Assignment No- 9
Roll No-
uploadform.html
<html>
<body>
<form action="uploader.php" method="post" enctype="multipart/form-data">
Select File:
<input type="file" name="fileToUpload"/>
<input type="submit" value="Upload Image" name="submit"/>
</form>
</body>
</html>
uploader.php
<?php
$target_path = "e:/";
$target_path = $target_path.basename( $_FILES['fileToUpload']['name']);
if(move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $target_path)) {
echo "File uploaded successfully!";
} else{
echo "Sorry, file not uploaded, please try again!";
}
?>
Output