PHP and MySQL Final Year Bca
PHP and MySQL Final Year Bca
AISHWARYA
ASSISTANT PROFESSOR
WHAT IS PHP?
PHP (Hypertext Preprocessor), originally standing for "Personal Home Page," is a widely-used open-source
server-side scripting language primarily designed for web development. It was created by Rasmus Lerdorf in
1994 as a set of Common Gateway Interface (CGI) binaries written in C to manage his personal website. Over
time, PHP evolved significantly:
1. PHP/FI (Forms Interpreter) 2.0 (1997): The first major version of PHP was developed to handle forms and
interact with databases. This version laid the foundation for the language's growth.
2. PHP 3 (1997): Israeli developers Zeev Suraski and Andi Gutman's rewrote PHP's parser in C, resulting in
PHP 3. This version dramatically improved performance and capabilities, making PHP more robust and
efficient.
3. PHP 4 (2000): PHP 4 introduced support for object-oriented programming (OOP), which
allowed developers to write more structured, reusable code. It also included many performance
improvements, shaping PHP into a modern language.
4. PHP 5 (2004): This version further improved OOP support, adding features like interfaces,
abstract classes, and exception handling. PHP 5 became a key version for enterprise-level web
applications.
5. PHP 7 (2015): PHP 7 was a major performance upgrade, making it up to twice as fast as
PHP 5.x. It also introduced new features such as scalar type declarations and return type
declarations, improving code clarity and reliability.
6. PHP 8 (2020): PHP 8 introduced Just-In-Time (JIT) compilation, which improved execution
speed for certain types of code. It also brought new features and enhancements such as named
arguments, union types, and match expressions, strengthening PHP’s capabilities for modern
development.
FEATURES OF PHP
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.
Familiarity with syntax: 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.
Security: PHP is a secure language to develop the website. It consists of multiple layers of
security to prevent threads and malicious attacks.
WHITE SPACE
White Space is a property defined in CSS (Cascading Style Sheets) that enable the user to control the text
wrapping and white spaces inside an element of the website. It can take several types of values depending
upon the user's need.
1. white-space: value;
Several values that can be passed to the white-space property are:
1. white-space: normal;
2. white-space: nowrap;
3. white-space: pre;
4. white-space: pre-wrap;
5. white-space: pre-line;
6. white space: break-spaces;
1.(normal wrapping):
Text will wrap to the next line when it hits the edge of the container.
The text fits inside the box.
2. (nowrap):
The text does not wrap and stays on one line.
If the text is too long, it will overflow outside the box.
Example:
<?php
$text = "This is a long sentence that might not fit in the box.";
?>
3.(pre):
Spaces and line breaks are preserved.
The text does not wrap to the next line, so it overflows if it’s too long for the container.
4.(pre-wrap):
Spaces and line breaks are preserved.
The text wraps to the next line when it reaches the container's edge.
Example:
<?php
// Text with extra spaces and line breaks
$text = "This is an example with:\n\n1. Extra spaces\n2. Line breaks\n3. Long
text that might overflow.";
?>
5.(pre-line):
Collapses multiple spaces into a single space.
Preserves line breaks in the text.
The text wraps within the container.
Example: "This is an example with:“
6. (break-spaces):
Preserves all spaces exactly as written (does not collapse spaces).
Preserves line breaks.
Spaces at the end of the line are also preserved.
Example: "This is an example with:“
Example:
<?php
// Text with extra spaces and line breaks
$text = "This is an example with:\n\n1. Extra spaces\n2. Line breaks\n3. Long
text with spaces.";
?>
Commenting in PHP :
Single-line comments:
1. Single-line comments are generally used for short explanations or notes
relevant to the local code.
2. There are two syntaxes for single-line comments in PHP:
Using #:
<?
# This is a comment, and
# This is the second line of the comment
// This is a comment too. Each style comments only
print "An example with single line comments";
?>
Multi-line comments:
1. Multi-line comments are generally used to provide pseudocode algorithms and
more detailed explanations when necessary.
2. The syntax for multi-line comments in PHP is the same as in CHere's an
example:
<?
/* This is a comment with multiline
Author: Mohammad Mohtashim
Purpose: Multiline Comments Demo
Subject: PHP
*/
print "An example with multi line comments";