This document provides an introduction to the PHP programming language. It discusses PHP's syntax which is inspired by C with curly braces and semicolons, and Perl with dollar signs for variables and associative arrays. PHP code can be embedded within HTML files to dynamically output content. The document also covers PHP variables, data types, expressions, operators, control structures like if/else statements, and functions like echo to output values.
The document provides an introduction to the PHP programming language. It discusses PHP's syntax, which is inspired by C with curly braces and semicolons, and Perl with dollar signs for variables. PHP code can be embedded within HTML files. The philosophy of PHP is that it aims to be convenient for programmers. Basic PHP syntax and keywords are also covered, along with variables, strings, expressions, output, comments, and control structures like if/else statements and while loops.
PHP is a scripting language commonly used for web development. It has syntax inspired by C and Perl and allows embedding PHP code segments within HTML files. PHP code is interpreted and executed on the server side to generate dynamic web page content. Key PHP constructs include variables, data types, operators, conditional and looping control structures, and functions. PHP aims to be convenient for programmers while sometimes failing silently on errors.
Perl is a high-level scripting language useful for tasks like parsing and restructuring data files, CGI scripts, and more. It was created in 1987 by Larry Wall as a "glue" language to connect systems. Perl code is compiled at runtime. Key features include regular expressions, hashes for associative arrays, object-oriented capabilities, and extensive standard and third-party libraries. Perl uses C-like syntax and data types like scalars, lists, and hashes. It supports control structures like if/else, for loops, and subroutines for modular programming. Perl is well-suited for text manipulation and system administration tasks.
This document provides a summary of a tutorial on learning the Perl 6 programming language. It covers topics like scalars, variables, control structures, I/O, subroutines, regular expressions, modules, classes and objects. It suggests that in the 80 minute session, the presenters will be able to cover data, variables, control structures, I/O, subroutines and regular expressions, but may not have time for everything. It also provides information on getting started with Pugs and writing simple Perl 6 programs, as well as examples of core Perl 6 concepts like objects, methods, strings, arithmetic, conditionals and loops.
1) The document provides an introduction to PHP basics including variables, data types, operators, and form handling. It explains how to store data in variables, assign values, destroy variables, and inspect variable contents.
2) Various PHP data types are covered such as integers, floats, strings, booleans, and NULL. Arithmetic, comparison, logical and assignment operators are also explained.
3) The document demonstrates how to manipulate variables using operators, perform arithmetic operations, concatenate strings, compare variables, and perform logical tests.
Full-day tutorial for the dutch php conference 2011 giving a very quick tour around all the various areas of the ZCE syllabus and some tips on the exam styles
This document provides an overview of PHP including:
- Basic PHP syntax like variables, data types, operators, and control structures
- Functions - both built-in and user-defined, including arguments and return values
- Loops - while, do-while, for, foreach
- Object-oriented concepts like classes, objects, constructors, inheritance
- Arrays - indexed, associative, and multidimensional
- Strings and math functions
- An introduction to abstraction and object-oriented programming principles in PHP
The document provides an introduction to the PHP programming language. It discusses PHP's syntax, which is inspired by C with curly braces and semicolons, and Perl with dollar signs for variables. PHP code can be embedded within HTML files. The philosophy of PHP is that it aims to be convenient for programmers. Basic PHP syntax and keywords are also covered, along with variables, strings, expressions, output, comments, and control structures like if/else statements and while loops.
PHP is a scripting language commonly used for web development. It has syntax inspired by C and Perl and allows embedding PHP code segments within HTML files. PHP code is interpreted and executed on the server side to generate dynamic web page content. Key PHP constructs include variables, data types, operators, conditional and looping control structures, and functions. PHP aims to be convenient for programmers while sometimes failing silently on errors.
Perl is a high-level scripting language useful for tasks like parsing and restructuring data files, CGI scripts, and more. It was created in 1987 by Larry Wall as a "glue" language to connect systems. Perl code is compiled at runtime. Key features include regular expressions, hashes for associative arrays, object-oriented capabilities, and extensive standard and third-party libraries. Perl uses C-like syntax and data types like scalars, lists, and hashes. It supports control structures like if/else, for loops, and subroutines for modular programming. Perl is well-suited for text manipulation and system administration tasks.
This document provides a summary of a tutorial on learning the Perl 6 programming language. It covers topics like scalars, variables, control structures, I/O, subroutines, regular expressions, modules, classes and objects. It suggests that in the 80 minute session, the presenters will be able to cover data, variables, control structures, I/O, subroutines and regular expressions, but may not have time for everything. It also provides information on getting started with Pugs and writing simple Perl 6 programs, as well as examples of core Perl 6 concepts like objects, methods, strings, arithmetic, conditionals and loops.
1) The document provides an introduction to PHP basics including variables, data types, operators, and form handling. It explains how to store data in variables, assign values, destroy variables, and inspect variable contents.
2) Various PHP data types are covered such as integers, floats, strings, booleans, and NULL. Arithmetic, comparison, logical and assignment operators are also explained.
3) The document demonstrates how to manipulate variables using operators, perform arithmetic operations, concatenate strings, compare variables, and perform logical tests.
Full-day tutorial for the dutch php conference 2011 giving a very quick tour around all the various areas of the ZCE syllabus and some tips on the exam styles
This document provides an overview of PHP including:
- Basic PHP syntax like variables, data types, operators, and control structures
- Functions - both built-in and user-defined, including arguments and return values
- Loops - while, do-while, for, foreach
- Object-oriented concepts like classes, objects, constructors, inheritance
- Arrays - indexed, associative, and multidimensional
- Strings and math functions
- An introduction to abstraction and object-oriented programming principles in PHP
This document provides an overview of PHP (Hypertext Preprocessor), a popular server-side scripting language used for web development. It discusses key PHP concepts like server-side scripting, inclusion of files, syntax, variables, arrays, operators, functions, branching, looping, forms, MySQL integration, sessions, and cookies. The document is intended to help beginners get started with PHP.
PHP is a scripting language commonly used for web development. It allows dynamic generation of web page content through embedded PHP code. Some key things PHP can do include interacting with databases, processing user input, file handling, and more. PHP code is embedded within HTML using <?php ?> tags and variables, control structures, and other programming elements allow writing logic and dynamic functionality.
Types of Strings in PHP discusses different string data types and functions in PHP. There are single-quoted and double-quoted strings, which can contain variables and escape characters respectively. Common string functions include substr() to extract substrings, str_replace() to replace substrings, and strpos() to find the position of a substring. Other useful functions are strrev() to reverse a string, str_pad() to pad a string to a length, and explode/implode to split/join strings.
1. The document discusses operators and flow control in PHP including math operators, assignment operators, comparison operators, logical operators, and control structures like if/else statements, switch statements, loops, and functions.
2. Regular expressions and pattern matching are introduced as ways to validate user input data with functions like ereg(), split(), and ereg_replace(). Common patterns and character classes are explained.
3. Form validation is discussed including checking for empty fields, using custom arrays for form data, and redirecting with HTTP headers. Server variables are also described.
This document provides an introduction and overview of the Perl 6 programming language. It covers topics such as getting started with Perl 6 using Pugs, basic program structure, scalars, variables, control structures, arrays, hashes, input/output, and more. The summary is designed to give a high-level understanding of the key topics covered in the document in 3 sentences or less.
This document provides an introduction to PHP including:
- PHP code uses <?php ?> tags and semicolons to end statements. It is loosely typed and supports variables, arrays, and objects.
- Built-in variables like $_GET and $_SERVER provide access to server and request data. Strings support escape sequences and variable interpolation.
- PHP has advantages like being open source, easy to learn, and having a large community, but disadvantages include loose syntax that can cause errors and previous lack of object orientation.
This document provides an introduction to Perl programming by discussing what Perl is used for, why it is useful, and how to get started with the language. It covers installing Perl on Windows and Linux, using variables and data structures like scalars, arrays, hashes, and references. It also demonstrates basic Perl syntax like conditional statements, loops, file I/O, and running commands. The goal is to get readers writing basic Perl code quickly while highlighting some key features of the language.
This document provides an overview of the Perl programming language. It discusses that Perl uses an interpreter to run code without compilation, and that it is easy to learn, program, and debug in Perl. The document then covers Perl installation, variables, data types, control structures, modules, and provides an example of a basic phonebook program to demonstrate hashes.
This document provides an overview of PHP syntax, variables, data types, operators, and other basic concepts. PHP scripts begin with <?php and end with ?>, variables start with $ and have naming rules, and there are different data types including string, integer, float, boolean, array, object and NULL. Operators allow performing actions on variables like arithmetic, comparison, increment/decrement, logical, string and array operations.
The document provides an introduction to PHP including PHP tags, comments, data types, variables, control structures, functions and more. It explains that PHP code is placed between <?php ?> tags and describes the different tags like <?php ?> for PHP code, <!-- --> for HTML comments. It also summarizes key PHP concepts like variables, arrays, strings, operators, if/else statements, loops, functions and built-in PHP functions.
PHP is a server-side scripting language that was created by Rasmus Lerdoff in 1994 and released in 1998. Major versions include PHP 3 in 1998, PHP 4 in 2000 which improved speed and reliability, and PHP 5 in 2004 which added improved object-oriented programming support. The latest version is PHP 7.4 released in 2019. PHP is an open source language that is widely used for web development due to its ease of use, flexibility, and built-in support for connecting to databases. It allows placing PHP code into HTML files which is then executed on the server and plain HTML is sent to browsers.
PHP is a server-side scripting language that can be embedded into HTML. It is used to dynamically generate client-side code sent as the HTTP response. PHP code is executed on the web server and allows variables, conditional statements, loops, functions, and arrays to dynamically output content. Key features include PHP tags <?php ?> to delimit PHP code, the echo command to output to the client, and variables that can store different data types and change types throughout a program.
PHP is a server-side scripting language that can be embedded into HTML. It is used to dynamically generate client-side code sent as the HTTP response. PHP code is executed on the web server and allows variables, conditional statements, loops, functions, and arrays to dynamically output content. Key features include PHP tags <?php ?> to delimit PHP code, the echo command to output to the client, and variables that can store different data types and change types throughout a program.
This document provides an overview of key PHP concepts including:
1) PHP requires statements to end with semicolons and supports different comment styles.
2) PHP supports scalar, compound, and special types like booleans, integers, strings, arrays, objects, resources and NULL.
3) Strings can be specified using single quotes, double quotes, heredoc, and nowdoc syntax. Variable names are expanded in double-quoted strings.
4) Arrays are ordered maps that can be created using array syntax or short array syntax, and elements accessed using square brackets.
The document provides an overview of an introduction to Perl programming course. It covers topics that will be discussed including creating and running Perl programs, variables, operators, functions, input/output, and conditional statements. The schedule lists times for beginning sessions, breaks, and ending each day. Resources for slides and mailing lists are also provided.
This document provides an overview of PHP including what it is used for, its basic syntax and features. PHP is a server-side scripting language used to build dynamic web applications. It allows embedding code within HTML pages that is executed on the server to produce dynamic web content. The document covers key PHP elements like variables, constants, comments and the echo statement used to output data to the browser. It provides code examples to demonstrate PHP syntax and how to define variables, constants and use echo.
The document discusses various techniques for extending and improving Perl, including both good and potentially evil techniques. It covers Perl modules that port Perl 6 features to Perl 5 like given/when switches and state variables. It also discusses techniques for runtime introspection and modification like PadWalker and source filters. The document advocates for continuing to extend Perl 5 with modern features to keep it relevant and powerful.
This document discusses strings and arrays in PHP. It covers string functions like strlen(), strpos(), and substr() for inspecting, comparing, and manipulating strings. It also covers creating, accessing, and iterating through arrays, including multidimensional arrays. Functions like count(), current(), next(), reset(), and foreach are described for working with arrays. The document also introduces numerical types in PHP like integers and floats.
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering CollegeDhivyaa C.R
This document discusses strings and arrays in PHP. It covers:
- Defining strings using quotes, concatenation, and heredoc syntax
- Common string functions like length, position, comparison, replacement
- Creating arrays using assignment, array() constructor, and functions
- Retrieving array values by index and with list()
- Multidimensional arrays containing other arrays
- The document provides examples of each PHP string and array concept.
This document provides an overview of PHP (Hypertext Preprocessor), a popular server-side scripting language used for web development. It discusses key PHP concepts like server-side scripting, inclusion of files, syntax, variables, arrays, operators, functions, branching, looping, forms, MySQL integration, sessions, and cookies. The document is intended to help beginners get started with PHP.
PHP is a scripting language commonly used for web development. It allows dynamic generation of web page content through embedded PHP code. Some key things PHP can do include interacting with databases, processing user input, file handling, and more. PHP code is embedded within HTML using <?php ?> tags and variables, control structures, and other programming elements allow writing logic and dynamic functionality.
Types of Strings in PHP discusses different string data types and functions in PHP. There are single-quoted and double-quoted strings, which can contain variables and escape characters respectively. Common string functions include substr() to extract substrings, str_replace() to replace substrings, and strpos() to find the position of a substring. Other useful functions are strrev() to reverse a string, str_pad() to pad a string to a length, and explode/implode to split/join strings.
1. The document discusses operators and flow control in PHP including math operators, assignment operators, comparison operators, logical operators, and control structures like if/else statements, switch statements, loops, and functions.
2. Regular expressions and pattern matching are introduced as ways to validate user input data with functions like ereg(), split(), and ereg_replace(). Common patterns and character classes are explained.
3. Form validation is discussed including checking for empty fields, using custom arrays for form data, and redirecting with HTTP headers. Server variables are also described.
This document provides an introduction and overview of the Perl 6 programming language. It covers topics such as getting started with Perl 6 using Pugs, basic program structure, scalars, variables, control structures, arrays, hashes, input/output, and more. The summary is designed to give a high-level understanding of the key topics covered in the document in 3 sentences or less.
This document provides an introduction to PHP including:
- PHP code uses <?php ?> tags and semicolons to end statements. It is loosely typed and supports variables, arrays, and objects.
- Built-in variables like $_GET and $_SERVER provide access to server and request data. Strings support escape sequences and variable interpolation.
- PHP has advantages like being open source, easy to learn, and having a large community, but disadvantages include loose syntax that can cause errors and previous lack of object orientation.
This document provides an introduction to Perl programming by discussing what Perl is used for, why it is useful, and how to get started with the language. It covers installing Perl on Windows and Linux, using variables and data structures like scalars, arrays, hashes, and references. It also demonstrates basic Perl syntax like conditional statements, loops, file I/O, and running commands. The goal is to get readers writing basic Perl code quickly while highlighting some key features of the language.
This document provides an overview of the Perl programming language. It discusses that Perl uses an interpreter to run code without compilation, and that it is easy to learn, program, and debug in Perl. The document then covers Perl installation, variables, data types, control structures, modules, and provides an example of a basic phonebook program to demonstrate hashes.
This document provides an overview of PHP syntax, variables, data types, operators, and other basic concepts. PHP scripts begin with <?php and end with ?>, variables start with $ and have naming rules, and there are different data types including string, integer, float, boolean, array, object and NULL. Operators allow performing actions on variables like arithmetic, comparison, increment/decrement, logical, string and array operations.
The document provides an introduction to PHP including PHP tags, comments, data types, variables, control structures, functions and more. It explains that PHP code is placed between <?php ?> tags and describes the different tags like <?php ?> for PHP code, <!-- --> for HTML comments. It also summarizes key PHP concepts like variables, arrays, strings, operators, if/else statements, loops, functions and built-in PHP functions.
PHP is a server-side scripting language that was created by Rasmus Lerdoff in 1994 and released in 1998. Major versions include PHP 3 in 1998, PHP 4 in 2000 which improved speed and reliability, and PHP 5 in 2004 which added improved object-oriented programming support. The latest version is PHP 7.4 released in 2019. PHP is an open source language that is widely used for web development due to its ease of use, flexibility, and built-in support for connecting to databases. It allows placing PHP code into HTML files which is then executed on the server and plain HTML is sent to browsers.
PHP is a server-side scripting language that can be embedded into HTML. It is used to dynamically generate client-side code sent as the HTTP response. PHP code is executed on the web server and allows variables, conditional statements, loops, functions, and arrays to dynamically output content. Key features include PHP tags <?php ?> to delimit PHP code, the echo command to output to the client, and variables that can store different data types and change types throughout a program.
PHP is a server-side scripting language that can be embedded into HTML. It is used to dynamically generate client-side code sent as the HTTP response. PHP code is executed on the web server and allows variables, conditional statements, loops, functions, and arrays to dynamically output content. Key features include PHP tags <?php ?> to delimit PHP code, the echo command to output to the client, and variables that can store different data types and change types throughout a program.
This document provides an overview of key PHP concepts including:
1) PHP requires statements to end with semicolons and supports different comment styles.
2) PHP supports scalar, compound, and special types like booleans, integers, strings, arrays, objects, resources and NULL.
3) Strings can be specified using single quotes, double quotes, heredoc, and nowdoc syntax. Variable names are expanded in double-quoted strings.
4) Arrays are ordered maps that can be created using array syntax or short array syntax, and elements accessed using square brackets.
The document provides an overview of an introduction to Perl programming course. It covers topics that will be discussed including creating and running Perl programs, variables, operators, functions, input/output, and conditional statements. The schedule lists times for beginning sessions, breaks, and ending each day. Resources for slides and mailing lists are also provided.
This document provides an overview of PHP including what it is used for, its basic syntax and features. PHP is a server-side scripting language used to build dynamic web applications. It allows embedding code within HTML pages that is executed on the server to produce dynamic web content. The document covers key PHP elements like variables, constants, comments and the echo statement used to output data to the browser. It provides code examples to demonstrate PHP syntax and how to define variables, constants and use echo.
The document discusses various techniques for extending and improving Perl, including both good and potentially evil techniques. It covers Perl modules that port Perl 6 features to Perl 5 like given/when switches and state variables. It also discusses techniques for runtime introspection and modification like PadWalker and source filters. The document advocates for continuing to extend Perl 5 with modern features to keep it relevant and powerful.
This document discusses strings and arrays in PHP. It covers string functions like strlen(), strpos(), and substr() for inspecting, comparing, and manipulating strings. It also covers creating, accessing, and iterating through arrays, including multidimensional arrays. Functions like count(), current(), next(), reset(), and foreach are described for working with arrays. The document also introduces numerical types in PHP like integers and floats.
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering CollegeDhivyaa C.R
This document discusses strings and arrays in PHP. It covers:
- Defining strings using quotes, concatenation, and heredoc syntax
- Common string functions like length, position, comparison, replacement
- Creating arrays using assignment, array() constructor, and functions
- Retrieving array values by index and with list()
- Multidimensional arrays containing other arrays
- The document provides examples of each PHP string and array concept.
artificial intelligence and data science contents.pptxGauravCar
What is artificial intelligence? Artificial intelligence is the ability of a computer or computer-controlled robot to perform tasks that are commonly associated with the intellectual processes characteristic of humans, such as the ability to reason.
› ...
Artificial intelligence (AI) | Definitio
Design and optimization of ion propulsion dronebjmsejournal
Electric propulsion technology is widely used in many kinds of vehicles in recent years, and aircrafts are no exception. Technically, UAVs are electrically propelled but tend to produce a significant amount of noise and vibrations. Ion propulsion technology for drones is a potential solution to this problem. Ion propulsion technology is proven to be feasible in the earth’s atmosphere. The study presented in this article shows the design of EHD thrusters and power supply for ion propulsion drones along with performance optimization of high-voltage power supply for endurance in earth’s atmosphere.
Rainfall intensity duration frequency curve statistical analysis and modeling...bijceesjournal
Using data from 41 years in Patna’ India’ the study’s goal is to analyze the trends of how often it rains on a weekly, seasonal, and annual basis (1981−2020). First, utilizing the intensity-duration-frequency (IDF) curve and the relationship by statistically analyzing rainfall’ the historical rainfall data set for Patna’ India’ during a 41 year period (1981−2020), was evaluated for its quality. Changes in the hydrologic cycle as a result of increased greenhouse gas emissions are expected to induce variations in the intensity, length, and frequency of precipitation events. One strategy to lessen vulnerability is to quantify probable changes and adapt to them. Techniques such as log-normal, normal, and Gumbel are used (EV-I). Distributions were created with durations of 1, 2, 3, 6, and 24 h and return times of 2, 5, 10, 25, and 100 years. There were also mathematical correlations discovered between rainfall and recurrence interval.
Findings: Based on findings, the Gumbel approach produced the highest intensity values, whereas the other approaches produced values that were close to each other. The data indicates that 461.9 mm of rain fell during the monsoon season’s 301st week. However, it was found that the 29th week had the greatest average rainfall, 92.6 mm. With 952.6 mm on average, the monsoon season saw the highest rainfall. Calculations revealed that the yearly rainfall averaged 1171.1 mm. Using Weibull’s method, the study was subsequently expanded to examine rainfall distribution at different recurrence intervals of 2, 5, 10, and 25 years. Rainfall and recurrence interval mathematical correlations were also developed. Further regression analysis revealed that short wave irrigation, wind direction, wind speed, pressure, relative humidity, and temperature all had a substantial influence on rainfall.
Originality and value: The results of the rainfall IDF curves can provide useful information to policymakers in making appropriate decisions in managing and minimizing floods in the study area.
Discover the latest insights on Data Driven Maintenance with our comprehensive webinar presentation. Learn about traditional maintenance challenges, the right approach to utilizing data, and the benefits of adopting a Data Driven Maintenance strategy. Explore real-world examples, industry best practices, and innovative solutions like FMECA and the D3M model. This presentation, led by expert Jules Oudmans, is essential for asset owners looking to optimize their maintenance processes and leverage digital technologies for improved efficiency and performance. Download now to stay ahead in the evolving maintenance landscape.
Applications of artificial Intelligence in Mechanical Engineering.pdfAtif Razi
Historically, mechanical engineering has relied heavily on human expertise and empirical methods to solve complex problems. With the introduction of computer-aided design (CAD) and finite element analysis (FEA), the field took its first steps towards digitization. These tools allowed engineers to simulate and analyze mechanical systems with greater accuracy and efficiency. However, the sheer volume of data generated by modern engineering systems and the increasing complexity of these systems have necessitated more advanced analytical tools, paving the way for AI.
AI offers the capability to process vast amounts of data, identify patterns, and make predictions with a level of speed and accuracy unattainable by traditional methods. This has profound implications for mechanical engineering, enabling more efficient design processes, predictive maintenance strategies, and optimized manufacturing operations. AI-driven tools can learn from historical data, adapt to new information, and continuously improve their performance, making them invaluable in tackling the multifaceted challenges of modern mechanical engineering.
Software Engineering and Project Management - Introduction, Modeling Concepts...Prakhyath Rai
Introduction, Modeling Concepts and Class Modeling: What is Object orientation? What is OO development? OO Themes; Evidence for usefulness of OO development; OO modeling history. Modeling
as Design technique: Modeling, abstraction, The Three models. Class Modeling: Object and Class Concept, Link and associations concepts, Generalization and Inheritance, A sample class model, Navigation of class models, and UML diagrams
Building the Analysis Models: Requirement Analysis, Analysis Model Approaches, Data modeling Concepts, Object Oriented Analysis, Scenario-Based Modeling, Flow-Oriented Modeling, class Based Modeling, Creating a Behavioral Model.
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...IJECEIAES
Medical image analysis has witnessed significant advancements with deep learning techniques. In the domain of brain tumor segmentation, the ability to
precisely delineate tumor boundaries from magnetic resonance imaging (MRI)
scans holds profound implications for diagnosis. This study presents an ensemble convolutional neural network (CNN) with transfer learning, integrating
the state-of-the-art Deeplabv3+ architecture with the ResNet18 backbone. The
model is rigorously trained and evaluated, exhibiting remarkable performance
metrics, including an impressive global accuracy of 99.286%, a high-class accuracy of 82.191%, a mean intersection over union (IoU) of 79.900%, a weighted
IoU of 98.620%, and a Boundary F1 (BF) score of 83.303%. Notably, a detailed comparative analysis with existing methods showcases the superiority of
our proposed model. These findings underscore the model’s competence in precise brain tumor localization, underscoring its potential to revolutionize medical
image analysis and enhance healthcare outcomes. This research paves the way
for future exploration and optimization of advanced CNN models in medical
imaging, emphasizing addressing false positives and resource efficiency.
3. About the PHP Language
• Syntax inspired by C
- Curly braces, semicolons, no significant whitespace
• Syntax inspired by perl
- Dollar signs to start variable names, associative arrays
• Extends HTML to add segments of PHP within an HTML
file
4. Philosophy of PHP
• You are a responsible and intelligent programmer.
• You know what you want to do.
• Some flexibility in syntax is OK - style choices are OK.
• Let’s make this as convenient as possible.
• Sometimes errors fail silently.
5. <h1>Hello from Dr. Chuck's HTML Page</h1>
<p>
<?php
echo "Hi there.n";
$answer = 6 * 7;
echo "The answer is $answer, what ";
echo "was the question again?n";
?>
</p>
<p>Yes another paragraph.</p>
6. <h1>Hello from Dr. Chuck's HTML Page</h1>
<p>
<?php
echo "Hi there.n";
$answer = 6 * 7;
echo "The answer is $answer, what ";
echo "was the question again?n";
?>
</p>
<p>Yes another paragraph.</p>
7. PHP from the Command Line
• You can run PHP from the
command line - the
output simply comes out
on the terminal.
• It does not have to be
part of a request-response
cycle.
<?php
echo("Hello World!");
echo("n");
?>
9. Keywords
http://php.net/manual/en/reserved.p
hp
abstract and array() as break case catch class
clone const continue declare default do else elseif
end declare endfor endforeach endif endswitch
endwhile extends final for foreach function global
goto if implements interface instanceof namespace
new or private protected public static switch
$this throw try use var while xor
10. Variable Names
• Start with a dollar sign ($) followed by a letter or
underscore, followed by any number of letters, numbers,
or underscores
• Case matters
http://php.net/manual/en/language.variables.basics.
php
$abc = 12;
$total = 0;
$largest_so_far = 0;
abc = 12;
$2php = 0;
$bad-punc = 0;
11. Variable Name Weirdness
Things that look like variables but are missing a dollar sign
can be confusing.
$x = 2;
$y = x + 5;
print $y;
$x = 2;
y = $x + 5;
print $x;
5 Parse error
12. Variable Name Weirdness
Things that look like variables but are missing a dollar sign
as an array index are unpredictable....
$x = 5;
$y = array("x" => "Hello");
print $y[x];
Hello
13. Strings / Different + Awesome
• String literals can use single quotes or double quotes.
• The backslash () is used as an “escape” character.
• Strings can span multiple lines - the newline is part of
the string.
• In double-quoted strings, variable values are expanded.
• Concatenation is the "." not "+" (more later).
http://php.net/manual/en/language.types.strin
g.php
14. <?php
echo "this is a simple stringn";
echo "You can also have embedded newlines in
strings this way as it is
okay to do";
// Outputs: This will expand:
// a newline
echo "This will expand: na newline";
// Outputs: Variables do 12
$expand = 12;
echo "Variables do $expandn";
Double
Quote
15. <?php
echo 'this is a simple string';
echo 'You can also have embedded newlines in
strings this way as it is
okay to do';
// Outputs: Arnold once said: "I'll be back"
echo 'Arnold once said: "I'll be back"';
// Outputs: This will not expand: n a newline
echo 'This will not expand: n a newline';
// Outputs: Variables do not $expand $either
echo 'Variables do not $expand $either';
Single
Quote
17. Output
• echo is a language construct -
can be treated like a function
with one parameter. Without
parentheses, it accepts
multiple parameters.
• print is a function - only one
parameter, but parentheses are
optional so it can look like a
language construct.
<?php
$x = "15" + 27;
echo $x;
echo("n");
echo $x, "n";
print $x;
print "n";
print($x);
print("n");
?>
19. Expressions
• Completely normal like other languages ( + - / * )
• More aggressive implicit type conversion
<?php
$x = "15" + 27;
echo($x);
echo("n");
?>
42
20. Expressions
• Expressions evaluate to a value. The value can be a
string, number, boolean, etc.
• Expressions often use operations and function calls.
There is an order of evaluation when there is more than
one operator in an expression.
• Expressions can also produce objects like arrays.
22. Increment / Decrement
• These operators allow you to both retrieve and
increment / decrement a variable.
• They are generally avoided in civilized code.
$x = 12;
$y = 15 + $x++;
echo "x is $x and y is $y n";
x is 13 and y is 27
23. Increment / Decrement
• These operators allow you to both retrieve and
increment / decrement a variable.
• They are generally avoided in civilized code.
$x = 12;
$y = 15 + $x;
$x = $x + 1;
echo "x is $x and y is $y n";
x is 13 and y is 27
24. String Concatenation
PHP uses the period character for concatenation, because
the plus character would instruct PHP to do the best it could
to add the two things together, converting if necessary.
$a = 'Hello ' . 'World!';
echo $a . "n";
Hello World!
25. Ternary
The ternary operator comes from C. It allows conditional
expressions. It is like a one-line if-then-else. Like all
“contraction” syntaxes, we must use it carefully.
$www = 123;
$msg = $www > 100 ? "Large" : "Small" ;
echo "First: $msg n";
$msg = ( $www % 2 == 0 ) ? "Even" : "Odd";
echo "Second: $msg n";
$msg = ( $www % 2 ) ? "Odd" : "Even";
echo "Third: $msg n";
First: Large
Second: Odd
Third: Odd
26. Side-Effect Assignment
These are pure contractions. Use them sparingly.
echo "n";
$out = "Hello";
$out = $out . " ";
$out .= "World!";
$out .= "n";
echo $out;
$count = 0;
$count += 1;
echo "Count: $countn";
Hello World!
Count: 1
27. Conversion / Casting
As PHP evaluates expressions, sometimes values in the
expression need to be converted from one type to another as
the computations are done.
• PHP does aggressive implicit type conversion (casting).
• You can also make type conversion (casting) explicit with
casting operators.
29. PHP vs. Python
$x = "100" + 25;
echo "X: $xn";
$y = "100" . 25;
echo "Y: $yn";
$z = "sam" + 25;
echo "Z: $zn";
X: 125
Y: 10025
Z: 25
x = int("100") + 25
print "X:", x
y = "100" + str(25)
print "Y:", y
z = int("sam") + 25
print "Z:", z
X: 125
Y: 10025
Traceback:"cast.py", line 5
z = int("sam") + 25;
ValueError: invalid literal
30. Casting
echo "A".FALSE."Bn";
echo "X".TRUE."Yn";
AB
X1Y
The concatenation operator tries to
convert its operands to strings.
TRUE becomes an integer 1 and
then becomes a string. FALSE is
“not there” - it is even “smaller”
than zero, at least when it comes to
width.
31. Equality versus Identity
The equality operator (==) in PHP is far more aggressive
than in most other languages when it comes to data
conversion during expression evaluation.
if ( 123 == "123" ) print ("Equality 1n");
if ( 123 == "100"+23 ) print ("Equality 2n");
if ( FALSE == "0" ) print ("Equality 3n");
if ( (5 < 6) == "2"-"1" ) print ("Equality 4n");
if ( (5 < 6) === TRUE ) print ("Equality 5n");
40. $fuel = 10;
while ($fuel > 1) {
print "Vroom vroomn";
}
$fuel = 10;
while ($fuel > 1) {
print "Vroom vroomn";
$fuel = $fuel - 1;
}
A while loop is a “zero-trip”
loop with the test at the top
before the first iteration
starts. We hand construct
the iteration variable to
implement a counted loop.
41. $count = 1;
do {
echo "$count times 5 is " . $count * 5;
echo "n";
} while (++$count <= 5);
1 times 5 is 5
2 times 5 is 10
3 times 5 is 15
4 times 5 is 20
5 times 5 is 25
A do-while loop is a “one-
trip” loop with the test at the
bottom after the first
iteration completes.
42. for($count=1; $count<=6; $count++ ) {
echo "$count times 6 is " . $count * 6;
echo "n";
}
A for loop is the simplest
way to construct a counted
loop.
1 times 6 is 6
2 times 6 is 12
3 times 6 is 18
4 times 6 is 24
5 times 6 is 30
6 times 6 is 36
43. for($count=1; $count<=6; $count++ ) {
echo "$count times 6 is " . $count * 6;
echo "n";
} 1 times 6 is 6
2 times 6 is 12
3 times 6 is 18
4 times 6 is 24
5 times 6 is 30
6 times 6 is 36
A for loop is the simplest
way to construct a counted
loop.
Before loop
starts
Loop runs while TRUE (top-
test) Run after each
iteration.
44. for($count=1; $count<=600; $count++ ) {
if ( $count == 5 ) break;
echo "Count: $countn";
}
echo "Donen";
Breaking Out of a Loop
• The break statement ends the current loop and jumps to the
statement immediately following the loop.
• It is like a loop test that can happen anywhere in the body of the
loop.
Count: 1
Count: 2
Count: 3
Count: 4
Done
45. Finishing an Iteration with
continue
The continue statement ends the current iteration. jumps to the top
of the loop, and starts the next iteration.
for($count=1; $count<=10; $count++ ) {
if ( ($count % 2) == 0 ) continue;
echo "Count: $countn";
}
echo "Donen";
Count: 1
Count: 3
Count: 5
Count: 7
Count: 9
Done
46. Summary
This is a sprint through some of the
unique language features of PHP.
47. Acknowledgements / Contributions
These slides are Copyright 2010- Charles R. Severance
(www.dr-chuck.com) as part of www.wa4e.com and made
available under a Creative Commons Attribution 4.0 License.
Please maintain this last slide in all copies of the document to
comply with the attribution requirements of the license. If you
make a change, feel free to add your name and organization
to the list of contributors on this page as you republish the
materials.
Initial Development: Charles Severance, University of
Michigan School of Information
Insert new Contributors and Translators here including names
and dates
Continue new Contributors and Translators here
Editor's Notes
Note from Chuck. If you are using these materials, you can remove my name and URL from this replace it with your own, but please retain the CC-BY logo on the first page as well as retain the entire last page when you remix and republish these slides.
Note from Chuck. Please retain and maintain this page as you remix and republish these materials. Please add any of your own improvements or contributions.