Introduction to PHP: Declaring variables, data types, arrays, strings, operators, expressions, control structures, functions, Reading data from web form controls like text boxes, radio buttons, lists etc., Handling File Uploads, Connecting to database (MySQL as reference), executing simple queries, handling results, Handling sessions and cookies File Handling in PHP: File operations like opening, closing, reading, writing, appending, deleting etc. on text and binary files, listing directories
2. Syllabus
PHP Programming
Introduction to PHP: Declaring variables, data
types, arrays, strings, operators, expressions,
control structures, functions, Reading data from
web form controls like text boxes, radio buttons,
lists etc., Handling File Uploads, Connecting to
database (MySQL as reference), executing simple
queries, handling results, Handling sessions and
cookies File Handling in PHP: File operations like
opening, closing, reading, writing, appending,
deleting etc. on text and binary files, listing
directories
2
3. UNIT 1 : PHP Programming
Aim & Objective :
➢ To introduce PHP language for Server Side scripting.
➢ PHP file upload features allows you to upload binary and text files both.
Moreover, you can have the full control over the file to be uploaded
through PHP authentication and file operation functions.
PHP File Uploads
3
4. UNIT 1 : PHP Programming
Principles of File Upload:
➢ PHP allows you to upload single and multiple files through few lines of
code only.
➢PHP file upload facilities allows you to upload both type of files : binary and
text files. Moreover, you can have the full control over the file to be uploaded
through PHP authentication and file operation functions.
PHP File Uploads
4
5. UNIT 1 : PHP Programming
PHP $_FILES
➢ The PHP global $_FILES contains all the information of file.
➢ $_FILES contains 5 elements. Each elements first dimension is name of the
upload control.
➢ By the help of $_ FILES global, we can get file name, file type, file size, temp
file name and errors associated with file.
PHP File Uploads
5
7. UNIT 1 : PHP Programming
Elements of $_FILES
we are assuming that file name is jits.
$_FILES[‘jits']['name']
returns file name.
$_FILES[‘jits’]['type']
returns MIME type of the file. Ex: application /pdf, image/jpg
$_FILES[‘jits']['size']
returns size of the file (in bytes).
$_FILES[‘jits']['tmp_name']
returns temporary file name of the file which was stored on the server.
$_FILES[‘jits']['error']
returns error code associated with this file.
PHP File Uploads
7
8. UNIT 1 : PHP Programming
is_uploaded_file() Function
➢By using this function, we can check whether the file is uploaded from client system to
server temporary location or not.
move_uploaded_file() function
➢The move_uploaded_file() function moves the uploaded file to a new location.
➢The move_uploaded_file() function checks internally if the file is uploaded through the
POST request. It moves the file if it is uploaded through the POST request.
PHP File Uploads
8
10. UNIT 1 : PHP Programming
<?php
if(is_uploaded_file($_FILES['myfile']['tmp_name']))
{
$fname=$_FILES['myfile']['name'];
if(move_uploaded_file($_FILES['myfile']['tmp_name'],"myfolder/$fname"))
{
echo "<b>$fname file is sucessfully uploaded <br><br>";
echo "Name of the Uploaded file is ". $_FILES['myfile']['name']. "<br>";
echo "Size of the file is :". $_FILES['myfile']['size']."<br>";
echo "tmp name of the file is :". $_FILES['myfile']['tmp_name']."<br>";
echo "Type of the file is :". $_FILES['myfile']['type'];
}
else
echo "file is not uploaded";
}
else
echo "not";
?>
PHP File Uploads
10
15. UNIT 1 : PHP Programming
PHP Text & Reference Books
15
Book Details :
TEXT BOOKS:
1. Web Technologies, Uttam K Roy, Oxford University Press
2. The Complete Reference PHP – Steven Holzner, Tata McGraw-Hill
REFERENCE BOOKS:
1.Web Programming, building internet applications, Chris Bates 2nd edition, Wiley Dreamtech
2. Java Server Pages –Hans Bergsten, SPD O’Reilly
3. Java Script, D. Flanagan, O’Reilly,SPD.
4. Beginning Web Programming-Jon Duckett WROX.
5. Programming World Wide Web, R. W. Sebesta, Fourth Edition, Pearson.
6. Internet and World Wide Web – How to program, Dietel and Nieto, Pearson.
16. UNIT 1 : PHP Programming
PHP Video reference
16
Video Link details (NPTEL, YOUTUBE Lectures and etc.)
https://nptel.ac.in/courses/106105084/
https://freevideolectures.com/course/3140/internet-technologies
https://www.btechguru.com/GATE--computer-science-and-engineering--web-technologies-
video-lecture--22--132.html
17. UNIT 1 : PHP Programming
PHP courses
17
courses available on <www.coursera.org>, and http://neat.aicte-india.org
https://www.coursera.org/
Course 1 : Web Applications for Everybody Specialization
Build dynamic database-backed web sites.. Use PHP, MySQL, jQuery, and Handlebars to build web
and database applications.
Course 2: Web Design for Everybody: Basics of Web Development & Coding Specialization
Learn to Design and Create Websites. Build a responsive and accessible web portfolio using
HTML5, CSS3, and JavaScript
19. UNIT 1 : PHP Programming
PHP MCQs
19
PHP – MCQs
1. What does PHP stand for?
i) Personal Home Page ii) Hypertext Preprocessor
iii) Pretext Hypertext Processor iv) Preprocessor Home Page
A. Both (i) and (ii) B. Both (ii) and (iv) C. Only (ii) D. Both (i) and (iii)
2. PHP files have a default file extension of.
A. .html B. .xml C. .php D. .ph
3. A PHP script should start with ---- and end with----:
A. < php > B. < ? php ?> C. < ? ? > D. < ?php ? >
4. Which of the looping statements is/are supported by PHP?
i) for loop ii) while loop iii) do-while loop iv) foreach loop
A. (i) and (ii) B. (i), (ii) and (iii)
C. All of the mentioned
D. None of the mentioned
20. UNIT 1 : PHP Programming
PHP Tutorial
20
PHP –Tutorial Problems:
1.Write a php program to read employee details
2.Write aphp program to uploads files to remote directory
21. UNIT 1 : PHP Programming
PHP Questions
21
PHP –universities & Important Questions:
1.What are the different types of errors in PHP?
2.What is the functionality of the function strstr and stristr?
3. Explain about various data types in PHP.
4. Explain about Arrays in PHP.
5. List and Explain the string functions in PHP.
6. List the statements that are used to connect PHP with MySQL.
7.How PHP is different from PHP Script? Explain.
8. Explain PHP form processing with an example.
9.How can I retrieve values from one database server and store them in other database server
using PHP?
10. What are the differences between Get and post methods in form submitting. Give the case
where we can use get and we can use post methods?