Download - Starting with PHP and Web devepolment
![Page 1: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/1.jpg)
PHP Web Development
Rajib Ahmed
![Page 2: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/2.jpg)
What we will see “Today”
Part 1– What is PHP?– History of PHP– Current Statistic of Apache PHP and MySQL– Setting up the Working environment– WAMP / LAMP / XAMP
![Page 3: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/3.jpg)
Cont.
Part 2– Our first Piece of CODE– PHP Variables– Conditional Statement and Loops– Arrays– Functions– Is PHP Object Orientated?
![Page 4: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/4.jpg)
MySQL
Part 3– MySQL– The Brothers PHP & MySQL– Data Base Basics– Our First Data Base – PhpMyAdmin– Data retrieval by PHP
![Page 5: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/5.jpg)
MBSTU.ac.bd Explained
Part 4– What Is CMS?– The Data base– Two part View– Some functions of mbstu.ac.bd– Best of CMS
![Page 6: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/6.jpg)
Advanced Topics
Part 5– Frameworks– Zend Frameworks– Web 2.0– JavaScript– AJAX– DoJo/ JQuery ?
![Page 7: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/7.jpg)
What is PHP?
PHP stands for "PHP Hypertext Preprocessor”
An embedded scripting language for HTML like ASP or JSP
A language that combines elements of Perl, C, and Java
![Page 8: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/8.jpg)
History of PHP
– Created by Rasmus Lerdorf in 1995 for tracking access to his resume
– Firstly Known as “Personal Home Page”
– Rewritten again in and released as version 2.0 in November of 1997
![Page 9: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/9.jpg)
History of PHP
– User base in 1998 estimated 10,000 users and 100,000 web sites installed
– Version 3.0 was released in June 1998 as PHP
– Php Current version of release is 5.2.5 November 2007
![Page 10: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/10.jpg)
Current Statistic
Performance*PHP pumped out about 47
pages/second Microsoft ASP pumped out about
43 pages/second Sun Java JSP pumped out about 13
pages/second
![Page 11: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/11.jpg)
Setting up Working Environment
Manual Configuration– Install Apache– Install PHP– Install MySQL– Configure Apache
![Page 12: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/12.jpg)
Config Apache
C:\apacheXX\
\Httpd.conf\
LoadModule Php5_module C:/php5/sapi/php5apache.ddl
AddType application/x-httpd-php .php .html
![Page 13: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/13.jpg)
WAMP/ LAMP/ XAMP
Preconfigured Package.WAMP => Windows Apache,MySQL
and PHPRun The installer on Windows.
![Page 14: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/14.jpg)
Bonus
Text Editor
– Notepad– Dream Weaver– PHP Designer– Eclipse
![Page 15: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/15.jpg)
PART 2
Our first Piece of CODE PHP Variables Conditional Statement and Loops Arrays Functions Is PHP Object Orientated?
![Page 16: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/16.jpg)
Our first Piece of CODE
The Script Tags– All PHP code is contained in one of several script
tags: <?
// Some code?>
<?php// Some code here?>
![Page 17: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/17.jpg)
The Hello World Example
<?php echo “Hello world”;
?>
Our first Piece of CODE
![Page 18: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/18.jpg)
Variables
All variables starts with $
i.e
$var1=“ Motiur Sir”
and
$var2=“ The Boss !!”
How to print “ Motiur Sir The Boss !!”
![Page 19: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/19.jpg)
Exapmle
The Hello World Example
<?php echo $var1.$var2;
?> Output
“ Motiur Sir The Boss !!”
![Page 20: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/20.jpg)
Conditional Statement
Conditional Statement
If (condition)
// some code
else
![Page 21: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/21.jpg)
Conditional Statement
Also
elseif (condition)
Switch (condition)
Case XX:
// Some codes
break;
![Page 22: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/22.jpg)
Arrays
Very important Topic Declaring an array
$arrayExample= array();
$arrayExample= array(
‘Nazrul Islam’,
‘Is’,
‘COOL’
);
![Page 23: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/23.jpg)
Built in Function : print_r()
I use this function for Debugging
print_r( $arrayExample );
Output:
Array ( [0] => Nazrul Islam
[1] => Is
[2] => COOl!! )
![Page 24: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/24.jpg)
Functions
Two Types of Functions– Built in Functions– User defined functions
![Page 25: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/25.jpg)
Built in Function Example
bool empty();empty -- Determine whether a variable is empty
bool isset();
isset -- Determine whether a variable is set .
string date();
date -- Format a local time/date
![Page 26: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/26.jpg)
User Defined Functions
Starts with keyword function Our first function
function you_fail ($name)
{echo “ Sorry $name you have failed ”
}
![Page 27: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/27.jpg)
Is PHP Object Orientated?
PHP is basically procedure oriented Scripting language
PHP is object oriented from PHP 4.xx– it had some limitations
PHP‘s OOP support is very good a PHP5
![Page 28: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/28.jpg)
MySQL
MySQL is a open source DatabaseThis year in February Sun Has bought
MySQL It very popular in the WWW
![Page 29: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/29.jpg)
The Brothers PHP & MySQL
There integration is great PHP has lots of built in functions MySQL PHP has built lots built in functions for other
databases too.– i.e. ORACLE, PostgreSQL, DB2
![Page 30: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/30.jpg)
Database Basics
Designing a database – Thinking about the relationship between data.
![Page 31: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/31.jpg)
First Normal Form
First Normal Form – Each column in a row must be atomic.– Each row in a table must contain the same
number of columns.– All rows in a table must be different.
![Page 32: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/32.jpg)
Second Normal form
The table must be in first normal form. All nonprimary key columns in the table must
be dependent on the entire primary key.
Why Normalization ?
![Page 33: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/33.jpg)
Why Normalization ?
– Key point : Reducing data redundancies.
![Page 34: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/34.jpg)
Our First Data Base
Creating a StudentInfo database on MySQL– Creating a Student table
fields– id– stu_name– stu_id– stu_faculty– stu_dept
![Page 35: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/35.jpg)
Use PhpMyAdmin
PhpMyAdmin is client program We will see the use PhpMyAdmin
![Page 36: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/36.jpg)
Data retrieval by PHP
Step1: setting up - user ,host, password Step2: connceting to mySQL Step3: selecting database
– selecting studentInfo database
![Page 37: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/37.jpg)
Step1
define ( host, "localhost");
define ( user, "root");
define ( pass, "");
define ( DB, “studentInfo");
![Page 38: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/38.jpg)
Step 2:
$con = mysql_connect ( host ,user ,pass );
if( ! $con)
{
echo "Error in connection ".mysql_error();
}
![Page 39: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/39.jpg)
Step 3
$DB_sel= mysql_select_db ( DB , $con);
if( ! $DB_sel )
{
echo “Database Not Found ".mysql_error();
}
![Page 40: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/40.jpg)
Query
$query_str =‘SELECT * FROM STUDETNS ’;
$result =mysql_query( $query_str );
![Page 41: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/41.jpg)
Displaying Results
while( $row = mysql_fetch_array ( $result ) )
{
echo
$row[ ‘stu_name’ ]. ’\’s roll is’ .$row [ ‘stu_roll’ ];
}
![Page 42: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/42.jpg)
MBSTU.ac.bd Explained
Part 4– The Data base– Two part View– Some functions of mbstu.ac.bd– What Is CMS?– Best of CMS
![Page 43: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/43.jpg)
MBSTU.ac.bd
![Page 44: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/44.jpg)
The Data base
Database name MBSTU
Tables on DB– faculty– department– menus– page– content– news
– teachers– teachers_designation– results– and more
![Page 45: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/45.jpg)
Relation between tables
![Page 46: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/46.jpg)
Two Part view
This is used for repetitive parts on the HTML pages
Header Footer Navigation
![Page 47: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/47.jpg)
Header
![Page 48: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/48.jpg)
Footer
![Page 49: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/49.jpg)
Navigation
![Page 50: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/50.jpg)
Some functions of mbstu.ac.bd
function get_all_faculty_name( ) function get_dept_name( ) function get_all_depertment_name( ) function get_page_content ( $page_id ) There is many more important and more
complex functions
![Page 51: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/51.jpg)
What is CMS
CMS is Content Management System Where Content is modified without editing
any HTML. mbstu.ac.bd is a custom CMS
![Page 52: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/52.jpg)
Joomla
This is a open source CMS It is the new buzz word in PHP world By learning Joomla you can real good jobs Look BDJobs.com for that.
![Page 53: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/53.jpg)
Advanced Topic
Part 5– Frameworks– Zend Frameworks– Web 2.0– JavaScript– AJAX– DoJo/ JQuery ?
![Page 54: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/54.jpg)
Frameworks
Frameworks is abstractions layer for implementing common tasks.
Frameworks implements “Design Patterns”
![Page 55: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/55.jpg)
Zend Frameworks
Zend is developed by Zeev Suraski and Andi Gutmans
This implements OOP Zend implements MVC ( Model, View,
Controller ) This will be a great Frameworks for future
![Page 56: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/56.jpg)
Ajax
Ajax is Asynchronous JavaScript XML This is not a programming language Its term Defining Web 2.0 Ajax example Google suggest, Google Maps
![Page 57: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/57.jpg)
DoJo / JQuery
This two JavaScript libraries are used for implementing Ajax.
![Page 58: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/58.jpg)
Conclusion
if you are planning a future in web development
HTML, CSS, PHP and Ajax will help you build one.
![Page 59: Starting with PHP and Web devepolment](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a69fed8b42a972b8b4aa4/html5/thumbnails/59.jpg)
Thank you allfor your patience