SlideShare una empresa de Scribd logo
1 de 48
Descargar para leer sin conexión
Introduction to PHP
PHP
PHP Hypertext Pre-processor
‚PHP is a server side scripting language‛
“Personal home page”
Generate HTML
Get index.php
1
3
4
pass index.php to PHP
interpretor
5
WebServer
Index.php in interpreted
HTMl form
Browser
2
Get index.php from
hard disk
What you mean by hypertext Pre-processor?
Scripting Languages
• A ‚script‛ is a collection of program or sequence of instructions that is
interpreted or carried out by another program rather than by the computer
processor. Two types of scripting languages are
– Client-side Scripting Language
– Server-side Scripting Language
• In server-side scripting, (such as PHP, ASP) the script is processed by the
server Like: Apache, ColdFusion, ISAPI and Microsoft's IIS on Windows.
• Client-side scripting such as JavaScript runs on the web browser.
What you mean by server side scripting??
•
Generate HTML
Get index.php
1
3
4
pass index.php to PHP
interpretor
5
WebServer
Index.php in interpreted
HTMl form
Browser
2
Get index.php from
hard disk
PHP is server side scripting
language because the php code
runs on the server and returns
the result in html form to the
client browser
What you mean by client side scripting??
•
Generate HTML
Get index.php
1
3
4
pass index.php to PHP
interpretor
5
WebServer
Index.php in interpreted
HTMl form
Browser
2
Get index.php from
hard disk
Client side scripting is something
where code runs on client
side(browser). For eg checking
whether a HTML text field contains
data or not can be done by running
a script from browser itself
Creating a PHP page
How to create a PHP page
1. Install Wamp (Windows-Apache-Mysql-PHP)
2. Create a new folder within WampWWW folder with the name
you want to give your project
• Eg: C:WampWWWmyProject
3. Right click and Create a new text file with extention ‚.php‛
• Eg: index.php
How to run PHP program
1. Start Wamp Server
2. Open your browser and type localhost/myProject/
3. Most of the browsers load the file with name ‚index‛ automatically. So it
is recommended to have the name ‚index‛ for your home page
Getting started with PHP programming
PHP Syntax
 Structurally similar to C/C++
 Supports procedural and object-oriented paradigm (to some degree)
 All PHP statements end with a semi-colon
 Each PHP script must be enclosed in the reserved PHP tag
<?php
//PHP code goes here..
?>
Other PHP tags
<?php
... Code
?>
Standard Tags
<?
... Code
?>
<?= $variable ?>
<script language=“php”>
... Code
</script>
<%
... Code
%>
Short Tags
Script TagsASP Tags
Commenting
// comment single line
/* comment
multiple lines */
//comment single line
/* Comment
multiple Lines*/
# comment single line-shell style
C PHP
Data Types
Data types
• PHP supports many different data types, but they are generally
divided in two categories:
• Scalar
» boolean :A value that can only either be true or false
» Int :A signed numeric integer value
» float : A signed floating-point value
» string : A collection of binary data
• Composite.
» Arrays
» Objects
Type Casting
 echo ((0.1 + 0.7) * 10); //Outputs 8
 echo (int) ((0.1 + 0.7) * 10); //Outputs 7
• This happens because the result of this simple arithmetic
expression is stored internally as 7.999999 instead of 8; when the
value is converted to int, PHP simply truncates away the fractional
part, resulting in a rather significant error (12.5%, to be exact).
Variables
Declaring a variable
//Declaring a variable
Int a=10;
Char c=‘a’;
Float f=1.12;
//Every variable starts with ‚$‚sign
//No need of prior Declarations
$a=10;
$c=‘a’;
$f=1.12;
C PHP
Variables
• Variables are temporary storage containers.
• In PHP, a variable can contain any type of data, such as, for example,
strings, integers, floating numbers, objects and arrays.
• PHP is loosely typed, meaning that it will implicitly change the type of a
variable as needed, depending on the operation being performed on its
value.
• This contrasts with strongly typed languages, like C and Java, where
variables can only contain one type of data throughout their existence.
Variable Variables
• In PHP, it is also possible to create so-called variable variables.
That is a variable whose name is contained in another variable.
For eg:
$name = ’foo’;
$$name = ’bar’;
echo $foo; // Displays ’bar’
function myFunc()
{
echo ’myFunc!’;
}
$f = ’myFunc’;
$f(); // will call myFunc();
Determining If a Variable Exists
• There is an inbuilt method called isset() which will return true if a
variable exists and has a value other than null
$x=12;
echo isset ($x); // returns true
echo isset($y); // returns false
Constants
Declaring a constant
//Declaring a constant using ‘const’
const int a=10;
int const a=10;
//Declaring a constant using ‘#define’
#define TRUE 1
#define FALSE 0
#define NAME_SIZE 20
define(’name’, ’baabtra’);
define(’EMAIL’, ’davey@php.net’);
echo EMAIL; // Displays ’davey@php.net’
echo name.PHP_EOL.email;
// Displays ’baabtra;
‘davey@php.net’
C PHP
Constants
• Conversely to variables, constants are meant for defining immutable values.
• Constants can be accessed for any scope within a script; however, they can
only contain scalar values.
• The built-in PHP_EOL constant represents the ‚end of line‛ marker.
OutPut
output
Int a=10,b=25;
Printf(‚%d %d‛,a,b);
$a=10; $b=25
Printf(‚%d %d‛,$a,$b);
print $a;
print $b; //Cannot take multiple arguments
echo $a,$b; //Fast and commonly used
die(‚the end‛);
exit(‚the end‛); // both allows to terminate
the script’s output by outputting a string
C PHP
echo Vs print
• echo is a language construct ( Constructs
are elements that are built-into the language
and, therefore, follow special rules)
• echo doesnt have a return value
• print() is not a language construct. It
is an inbuilt function only
• Always return 1 once it print
someting
Control structures
Control Structures
Conditional Control Structures
• If
• If else
• Switch
Loops
For
While
Do while
Other
• Break
• Continue
‚Exactly the same as on left side‛
C PHP
functions
Functions
Int findSum(int a,int b)
{
Int c;
c=a+b;
Return c
}
findSum(10,15);
function findSum($a,$b)
{
$c=$a+$b;
Return $c;
}
findSum(10,15);
C PHP
Function arguments
• You can define any number of arguments and, in fact, you can pass an
arbitrary number of arguments to a function, regardless of how many you
specified in its declaration.PHP will not complain unless you provide fewer
arguments than you declared
Eg:
function greeting($arg1)
{
echo ‚hello $ arg1‛;
}
greeting(‚baabtra‛);
greeting(‚baabtra‛, ‛baabte‛);
greeting(); // ERROR
Function arguments
• You can make arguments optional by giving them a default value.
function hello($who = "World")
{
echo "Hello $who";
}
hello(‘baabtra’); // hello baabtra
hello(); // hello world
Function arguments
PHP provides three built-in functions to handle variable-length
argument lists:
– func_num_args() : return the total number of arguments
– func_get_arg() : return the argument at any index position
– func_get_args() : returns an array of all argument
Function arguments
function hello()
{
if (func_num_args() > 0)
{
$arg = func_get_arg(0); // The first argument is at position 0
echo "Hello $arg";
}
else
{
echo "Hello World";
}
}
hello("Reader"); // Displays "Hello Reader"
hello(); // Displays "Hello World“
Function return type
• In PHP functions even if you don’t return a value, PHP will still
cause your function to return NULL. So there is no concept of
‘void’
Strings
Char a*+=‚Baabtra‛;
Printf(‚Hello %s‛,a);
$a=‚Baabtra‛;
echo ‚Hello $a‛; //Output: Hello baabtra;
echo ‘Hello $a’; //Outputs : Hello $a
‚Strings will be continued in coming
chapters‛
C PHP
Arrays
Indexed Array
int a[]={1,2,3,4,5,6,7,8,9,10};
for(i=0;i<10;i++)
Printf(‚%d‛,a[i]);
Indexed Array / Enumerated array
$a=array(1,2,3,4,5,6,7,8,9,10)
for($i=0;$i<10;$i++)
echo $a[$i] ;
Associative Array
$a*‘name’+=‚John‛;
$a*‘age’+=24;
$a*‘mark’+=35.65;
‚Array will be continued in coming
chapters‛
C PHP
Operators
Operators
C
Arithmetic Operators
+, ++, -, --, *, /, %
Comparison Operators
==, !=, ===, !==, >, >=, < , <=
Logical Operators
&&, ||, !
Assignment Operators
=, +=, -=, *=, /=, %=
PHP
‚Supports all on left . In addition
PHP supports below operators as well‛
• Execution Operators
• String operators
• Type Operators
• Error Control Operators
• Bitwise Operators
• The backtick operator makes it possible to execute a shell command and
retrieve its output. For example, the following will cause the output of the
UNIX ls commandto be stored inside $a:
Eg : $a = ‘ls -l‘;
Execution operator (‘)
Don’t confuse the backtick operator with regular quotes (and, conversely, don’t
confuse the latter with the former!)
– The dot (.) operator is used to concatenate two strings
Eg1: $string=‚baabtra‛. ‚mentoring parner‛
Eg2: $string1=‚baabtra‛;
$string2=‚mentoring parner‛;
$string3=$string1.$string2;
String operators (.)
– Used to determine whether a variable is an instantiated object of a certain class or
an object of a class that inherits from a parent class
Eg: class ParentClass
{ }
class MyClass extends ParentClass
{ }
$a = new MyClass;
var_dump($a instanceof MyClass); // returns true as $a is an object of MyClass
var_dump($a instanceof ParentClass); // returns true as $a is an object of MyClass
which inherits parentClass
Type operators (instanceof )
Error suppression operator (@)
• When prepended to an expression, this operator causes PHP to ignore
almost all error messages that occur while that expression is being evaluated
Eg: $x = @mysql_connect(‘localhost’,’root’,’1234’);
• The code above will prevent the call to mysql_connect() from outputting an
error—provided that the function uses PHP’s own functionality for
reporting errors.
• Sadly, some libraries output their errors directly, bypassing PHP and,
therefore, make it much harder to manage with the error-control operator.
• Bitwise operators allow you to manipulate bits of data. All these operators are
designed to work only on integer numbers—therefore, the interpreter will attempt
to convert their operands to integers before executing them.
Bitwise Operators
& Bitwise AND. The result of the operation will be a value whose bits are set if they are set in
both operands, and unset otherwise.
| Bitwise OR. The result of the operation will be a value whose bits are set if they are set in
either operand (or both), and unset otherwise.
ˆ Bitwise XOR (exclusive OR). The result of the operation will be a value whose bits are set if
they are set in either operand, and unset otherwise.
<< Bitwise left shift. This operation shifts the left-hand operand’s bits to the left by a number of
positions equal to the right operand, inserting unset bits in the shifted positions
>> Bitwise right shift. This operation shifts the left-hand operand’s bits to the right by a number
of positions equal to the right operand, inserting unset bits in the shifted positions.
Questions?
‚A good question deserve a good grade…‛
End of day
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards
 
php basics
php basicsphp basics
php basics
 
Introduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPIntroduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHP
 
PHP Workshop Notes
PHP Workshop NotesPHP Workshop Notes
PHP Workshop Notes
 
PHP slides
PHP slidesPHP slides
PHP slides
 
PHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet SolutionPHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet Solution
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
PHP Basic
PHP BasicPHP Basic
PHP Basic
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
Constructor and encapsulation in php
Constructor and encapsulation in phpConstructor and encapsulation in php
Constructor and encapsulation in php
 
Basic of PHP
Basic of PHPBasic of PHP
Basic of PHP
 
Php Lecture Notes
Php Lecture NotesPhp Lecture Notes
Php Lecture Notes
 
Php
PhpPhp
Php
 
Control Structures In Php 2
Control Structures In Php 2Control Structures In Php 2
Control Structures In Php 2
 
PHP Comprehensive Overview
PHP Comprehensive OverviewPHP Comprehensive Overview
PHP Comprehensive Overview
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Php(report)
Php(report)Php(report)
Php(report)
 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
 
Php i basic chapter 3
Php i basic chapter 3Php i basic chapter 3
Php i basic chapter 3
 

Destacado

MVC Frameworks for building PHP Web Applications
MVC Frameworks for building PHP Web ApplicationsMVC Frameworks for building PHP Web Applications
MVC Frameworks for building PHP Web ApplicationsVforce Infotech
 
Startup #7 : how to get customers
Startup #7 : how to get customersStartup #7 : how to get customers
Startup #7 : how to get customersJean Michel
 
PHP #1 : introduction
PHP #1 : introductionPHP #1 : introduction
PHP #1 : introductionJean Michel
 
Introduction To PHP
Introduction To PHPIntroduction To PHP
Introduction To PHPShweta A
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHPBradley Holt
 
Nnnnooemi pool riooss 1c
Nnnnooemi pool riooss 1cNnnnooemi pool riooss 1c
Nnnnooemi pool riooss 1cbeerseva95
 
Introduction to html 5
Introduction to html 5Introduction to html 5
Introduction to html 5Sayed Ahmed
 
Introduction to PHP H/MVC Frameworks by www.silicongulf.com
Introduction to PHP H/MVC Frameworks by www.silicongulf.comIntroduction to PHP H/MVC Frameworks by www.silicongulf.com
Introduction to PHP H/MVC Frameworks by www.silicongulf.comChristopher Cubos
 
Don't Fear the Regex - Northeast PHP 2015
Don't Fear the Regex - Northeast PHP 2015Don't Fear the Regex - Northeast PHP 2015
Don't Fear the Regex - Northeast PHP 2015Sandy Smith
 
/Regex makes me want to (weep|give up|(╯°□°)╯︵ ┻━┻)\.?/i
/Regex makes me want to (weep|give up|(╯°□°)╯︵ ┻━┻)\.?/i/Regex makes me want to (weep|give up|(╯°□°)╯︵ ┻━┻)\.?/i
/Regex makes me want to (weep|give up|(╯°□°)╯︵ ┻━┻)\.?/ibrettflorio
 
PHP Framework
PHP FrameworkPHP Framework
PHP Frameworkceleroo
 
Principles of MVC for PHP Developers
Principles of MVC for PHP DevelopersPrinciples of MVC for PHP Developers
Principles of MVC for PHP DevelopersEdureka!
 

Destacado (20)

PHP Templating Systems
PHP Templating SystemsPHP Templating Systems
PHP Templating Systems
 
MVC Frameworks for building PHP Web Applications
MVC Frameworks for building PHP Web ApplicationsMVC Frameworks for building PHP Web Applications
MVC Frameworks for building PHP Web Applications
 
Why MVC?
Why MVC?Why MVC?
Why MVC?
 
01 Php Introduction
01 Php Introduction01 Php Introduction
01 Php Introduction
 
Startup #7 : how to get customers
Startup #7 : how to get customersStartup #7 : how to get customers
Startup #7 : how to get customers
 
PHP #1 : introduction
PHP #1 : introductionPHP #1 : introduction
PHP #1 : introduction
 
Introduction To PHP
Introduction To PHPIntroduction To PHP
Introduction To PHP
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Nnnnooemi pool riooss 1c
Nnnnooemi pool riooss 1cNnnnooemi pool riooss 1c
Nnnnooemi pool riooss 1c
 
Introduction à HTML 5
Introduction à HTML 5Introduction à HTML 5
Introduction à HTML 5
 
Html 5 introduction
Html 5 introductionHtml 5 introduction
Html 5 introduction
 
Intro to html 5
Intro to html 5Intro to html 5
Intro to html 5
 
Introduction to html 5
Introduction to html 5Introduction to html 5
Introduction to html 5
 
Introduction to PHP H/MVC Frameworks by www.silicongulf.com
Introduction to PHP H/MVC Frameworks by www.silicongulf.comIntroduction to PHP H/MVC Frameworks by www.silicongulf.com
Introduction to PHP H/MVC Frameworks by www.silicongulf.com
 
Grokking regex
Grokking regexGrokking regex
Grokking regex
 
Don't Fear the Regex - Northeast PHP 2015
Don't Fear the Regex - Northeast PHP 2015Don't Fear the Regex - Northeast PHP 2015
Don't Fear the Regex - Northeast PHP 2015
 
/Regex makes me want to (weep|give up|(╯°□°)╯︵ ┻━┻)\.?/i
/Regex makes me want to (weep|give up|(╯°□°)╯︵ ┻━┻)\.?/i/Regex makes me want to (weep|give up|(╯°□°)╯︵ ┻━┻)\.?/i
/Regex makes me want to (weep|give up|(╯°□°)╯︵ ┻━┻)\.?/i
 
PHP Framework
PHP FrameworkPHP Framework
PHP Framework
 
Principles of MVC for PHP Developers
Principles of MVC for PHP DevelopersPrinciples of MVC for PHP Developers
Principles of MVC for PHP Developers
 

Similar a Introduction to php basics

PHP Introduction and Training Material
PHP Introduction and Training MaterialPHP Introduction and Training Material
PHP Introduction and Training MaterialManoj kumar
 
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Muhamad Al Imran
 
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Muhamad Al Imran
 
FYBSC IT Web Programming Unit IV PHP and MySQL
FYBSC IT Web Programming Unit IV  PHP and MySQLFYBSC IT Web Programming Unit IV  PHP and MySQL
FYBSC IT Web Programming Unit IV PHP and MySQLArti Parab Academics
 
PHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckPHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckrICh morrow
 
PHP-03-Functions.ppt
PHP-03-Functions.pptPHP-03-Functions.ppt
PHP-03-Functions.pptJamers2
 
Introduction To Php For Wit2009
Introduction To Php For Wit2009Introduction To Php For Wit2009
Introduction To Php For Wit2009cwarren
 
Hsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfHsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfAAFREEN SHAIKH
 

Similar a Introduction to php basics (20)

Prersentation
PrersentationPrersentation
Prersentation
 
PHP Introduction and Training Material
PHP Introduction and Training MaterialPHP Introduction and Training Material
PHP Introduction and Training Material
 
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
 
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
 
Lecture8
Lecture8Lecture8
Lecture8
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
Materi Dasar PHP
Materi Dasar PHPMateri Dasar PHP
Materi Dasar PHP
 
My cool new Slideshow!
My cool new Slideshow!My cool new Slideshow!
My cool new Slideshow!
 
slidesharenew1
slidesharenew1slidesharenew1
slidesharenew1
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
FYBSC IT Web Programming Unit IV PHP and MySQL
FYBSC IT Web Programming Unit IV  PHP and MySQLFYBSC IT Web Programming Unit IV  PHP and MySQL
FYBSC IT Web Programming Unit IV PHP and MySQL
 
PHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckPHP from soup to nuts Course Deck
PHP from soup to nuts Course Deck
 
Php
PhpPhp
Php
 
WT_PHP_PART1.pdf
WT_PHP_PART1.pdfWT_PHP_PART1.pdf
WT_PHP_PART1.pdf
 
PHP-03-Functions.ppt
PHP-03-Functions.pptPHP-03-Functions.ppt
PHP-03-Functions.ppt
 
PHP-03-Functions.ppt
PHP-03-Functions.pptPHP-03-Functions.ppt
PHP-03-Functions.ppt
 
basics of php
 basics of php basics of php
basics of php
 
Introduction in php
Introduction in phpIntroduction in php
Introduction in php
 
Introduction To Php For Wit2009
Introduction To Php For Wit2009Introduction To Php For Wit2009
Introduction To Php For Wit2009
 
Hsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfHsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdf
 

Más de baabtra.com - No. 1 supplier of quality freshers

Más de baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 

Último

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Último (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

Introduction to php basics

  • 2. PHP PHP Hypertext Pre-processor ‚PHP is a server side scripting language‛ “Personal home page”
  • 3. Generate HTML Get index.php 1 3 4 pass index.php to PHP interpretor 5 WebServer Index.php in interpreted HTMl form Browser 2 Get index.php from hard disk What you mean by hypertext Pre-processor?
  • 4. Scripting Languages • A ‚script‛ is a collection of program or sequence of instructions that is interpreted or carried out by another program rather than by the computer processor. Two types of scripting languages are – Client-side Scripting Language – Server-side Scripting Language • In server-side scripting, (such as PHP, ASP) the script is processed by the server Like: Apache, ColdFusion, ISAPI and Microsoft's IIS on Windows. • Client-side scripting such as JavaScript runs on the web browser.
  • 5. What you mean by server side scripting?? • Generate HTML Get index.php 1 3 4 pass index.php to PHP interpretor 5 WebServer Index.php in interpreted HTMl form Browser 2 Get index.php from hard disk PHP is server side scripting language because the php code runs on the server and returns the result in html form to the client browser
  • 6. What you mean by client side scripting?? • Generate HTML Get index.php 1 3 4 pass index.php to PHP interpretor 5 WebServer Index.php in interpreted HTMl form Browser 2 Get index.php from hard disk Client side scripting is something where code runs on client side(browser). For eg checking whether a HTML text field contains data or not can be done by running a script from browser itself
  • 8. How to create a PHP page 1. Install Wamp (Windows-Apache-Mysql-PHP) 2. Create a new folder within WampWWW folder with the name you want to give your project • Eg: C:WampWWWmyProject 3. Right click and Create a new text file with extention ‚.php‛ • Eg: index.php
  • 9. How to run PHP program 1. Start Wamp Server 2. Open your browser and type localhost/myProject/ 3. Most of the browsers load the file with name ‚index‛ automatically. So it is recommended to have the name ‚index‛ for your home page
  • 10. Getting started with PHP programming
  • 11. PHP Syntax  Structurally similar to C/C++  Supports procedural and object-oriented paradigm (to some degree)  All PHP statements end with a semi-colon  Each PHP script must be enclosed in the reserved PHP tag <?php //PHP code goes here.. ?>
  • 12. Other PHP tags <?php ... Code ?> Standard Tags <? ... Code ?> <?= $variable ?> <script language=“php”> ... Code </script> <% ... Code %> Short Tags Script TagsASP Tags
  • 13. Commenting // comment single line /* comment multiple lines */ //comment single line /* Comment multiple Lines*/ # comment single line-shell style C PHP
  • 15. Data types • PHP supports many different data types, but they are generally divided in two categories: • Scalar » boolean :A value that can only either be true or false » Int :A signed numeric integer value » float : A signed floating-point value » string : A collection of binary data • Composite. » Arrays » Objects
  • 16. Type Casting  echo ((0.1 + 0.7) * 10); //Outputs 8  echo (int) ((0.1 + 0.7) * 10); //Outputs 7 • This happens because the result of this simple arithmetic expression is stored internally as 7.999999 instead of 8; when the value is converted to int, PHP simply truncates away the fractional part, resulting in a rather significant error (12.5%, to be exact).
  • 18. Declaring a variable //Declaring a variable Int a=10; Char c=‘a’; Float f=1.12; //Every variable starts with ‚$‚sign //No need of prior Declarations $a=10; $c=‘a’; $f=1.12; C PHP
  • 19. Variables • Variables are temporary storage containers. • In PHP, a variable can contain any type of data, such as, for example, strings, integers, floating numbers, objects and arrays. • PHP is loosely typed, meaning that it will implicitly change the type of a variable as needed, depending on the operation being performed on its value. • This contrasts with strongly typed languages, like C and Java, where variables can only contain one type of data throughout their existence.
  • 20. Variable Variables • In PHP, it is also possible to create so-called variable variables. That is a variable whose name is contained in another variable. For eg: $name = ’foo’; $$name = ’bar’; echo $foo; // Displays ’bar’ function myFunc() { echo ’myFunc!’; } $f = ’myFunc’; $f(); // will call myFunc();
  • 21. Determining If a Variable Exists • There is an inbuilt method called isset() which will return true if a variable exists and has a value other than null $x=12; echo isset ($x); // returns true echo isset($y); // returns false
  • 23. Declaring a constant //Declaring a constant using ‘const’ const int a=10; int const a=10; //Declaring a constant using ‘#define’ #define TRUE 1 #define FALSE 0 #define NAME_SIZE 20 define(’name’, ’baabtra’); define(’EMAIL’, ’davey@php.net’); echo EMAIL; // Displays ’davey@php.net’ echo name.PHP_EOL.email; // Displays ’baabtra; ‘davey@php.net’ C PHP
  • 24. Constants • Conversely to variables, constants are meant for defining immutable values. • Constants can be accessed for any scope within a script; however, they can only contain scalar values. • The built-in PHP_EOL constant represents the ‚end of line‛ marker.
  • 26. output Int a=10,b=25; Printf(‚%d %d‛,a,b); $a=10; $b=25 Printf(‚%d %d‛,$a,$b); print $a; print $b; //Cannot take multiple arguments echo $a,$b; //Fast and commonly used die(‚the end‛); exit(‚the end‛); // both allows to terminate the script’s output by outputting a string C PHP
  • 27. echo Vs print • echo is a language construct ( Constructs are elements that are built-into the language and, therefore, follow special rules) • echo doesnt have a return value • print() is not a language construct. It is an inbuilt function only • Always return 1 once it print someting
  • 29. Control Structures Conditional Control Structures • If • If else • Switch Loops For While Do while Other • Break • Continue ‚Exactly the same as on left side‛ C PHP
  • 31. Functions Int findSum(int a,int b) { Int c; c=a+b; Return c } findSum(10,15); function findSum($a,$b) { $c=$a+$b; Return $c; } findSum(10,15); C PHP
  • 32. Function arguments • You can define any number of arguments and, in fact, you can pass an arbitrary number of arguments to a function, regardless of how many you specified in its declaration.PHP will not complain unless you provide fewer arguments than you declared Eg: function greeting($arg1) { echo ‚hello $ arg1‛; } greeting(‚baabtra‛); greeting(‚baabtra‛, ‛baabte‛); greeting(); // ERROR
  • 33. Function arguments • You can make arguments optional by giving them a default value. function hello($who = "World") { echo "Hello $who"; } hello(‘baabtra’); // hello baabtra hello(); // hello world
  • 34. Function arguments PHP provides three built-in functions to handle variable-length argument lists: – func_num_args() : return the total number of arguments – func_get_arg() : return the argument at any index position – func_get_args() : returns an array of all argument
  • 35. Function arguments function hello() { if (func_num_args() > 0) { $arg = func_get_arg(0); // The first argument is at position 0 echo "Hello $arg"; } else { echo "Hello World"; } } hello("Reader"); // Displays "Hello Reader" hello(); // Displays "Hello World“
  • 36. Function return type • In PHP functions even if you don’t return a value, PHP will still cause your function to return NULL. So there is no concept of ‘void’
  • 37. Strings Char a*+=‚Baabtra‛; Printf(‚Hello %s‛,a); $a=‚Baabtra‛; echo ‚Hello $a‛; //Output: Hello baabtra; echo ‘Hello $a’; //Outputs : Hello $a ‚Strings will be continued in coming chapters‛ C PHP
  • 38. Arrays Indexed Array int a[]={1,2,3,4,5,6,7,8,9,10}; for(i=0;i<10;i++) Printf(‚%d‛,a[i]); Indexed Array / Enumerated array $a=array(1,2,3,4,5,6,7,8,9,10) for($i=0;$i<10;$i++) echo $a[$i] ; Associative Array $a*‘name’+=‚John‛; $a*‘age’+=24; $a*‘mark’+=35.65; ‚Array will be continued in coming chapters‛ C PHP
  • 40. Operators C Arithmetic Operators +, ++, -, --, *, /, % Comparison Operators ==, !=, ===, !==, >, >=, < , <= Logical Operators &&, ||, ! Assignment Operators =, +=, -=, *=, /=, %= PHP ‚Supports all on left . In addition PHP supports below operators as well‛ • Execution Operators • String operators • Type Operators • Error Control Operators • Bitwise Operators
  • 41. • The backtick operator makes it possible to execute a shell command and retrieve its output. For example, the following will cause the output of the UNIX ls commandto be stored inside $a: Eg : $a = ‘ls -l‘; Execution operator (‘) Don’t confuse the backtick operator with regular quotes (and, conversely, don’t confuse the latter with the former!)
  • 42. – The dot (.) operator is used to concatenate two strings Eg1: $string=‚baabtra‛. ‚mentoring parner‛ Eg2: $string1=‚baabtra‛; $string2=‚mentoring parner‛; $string3=$string1.$string2; String operators (.)
  • 43. – Used to determine whether a variable is an instantiated object of a certain class or an object of a class that inherits from a parent class Eg: class ParentClass { } class MyClass extends ParentClass { } $a = new MyClass; var_dump($a instanceof MyClass); // returns true as $a is an object of MyClass var_dump($a instanceof ParentClass); // returns true as $a is an object of MyClass which inherits parentClass Type operators (instanceof )
  • 44. Error suppression operator (@) • When prepended to an expression, this operator causes PHP to ignore almost all error messages that occur while that expression is being evaluated Eg: $x = @mysql_connect(‘localhost’,’root’,’1234’); • The code above will prevent the call to mysql_connect() from outputting an error—provided that the function uses PHP’s own functionality for reporting errors. • Sadly, some libraries output their errors directly, bypassing PHP and, therefore, make it much harder to manage with the error-control operator.
  • 45. • Bitwise operators allow you to manipulate bits of data. All these operators are designed to work only on integer numbers—therefore, the interpreter will attempt to convert their operands to integers before executing them. Bitwise Operators & Bitwise AND. The result of the operation will be a value whose bits are set if they are set in both operands, and unset otherwise. | Bitwise OR. The result of the operation will be a value whose bits are set if they are set in either operand (or both), and unset otherwise. ˆ Bitwise XOR (exclusive OR). The result of the operation will be a value whose bits are set if they are set in either operand, and unset otherwise. << Bitwise left shift. This operation shifts the left-hand operand’s bits to the left by a number of positions equal to the right operand, inserting unset bits in the shifted positions >> Bitwise right shift. This operation shifts the left-hand operand’s bits to the right by a number of positions equal to the right operand, inserting unset bits in the shifted positions.
  • 46. Questions? ‚A good question deserve a good grade…‛
  • 48. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com