PHP is a widely used open source scripting language that can be embedded into HTML. PHP code is executed on the server and outputs HTML that is sent to the browser. PHP is free to download and use and can be used to create dynamic web page content, connect to databases, send and receive cookies, and more. Some key things needed to use PHP include a web server with PHP support, PHP files with a .php extension, and PHP code delimited by <?php ?> tags.
PHP is a widely used server-side scripting language that allows developers to create dynamic web pages. It can be embedded within HTML and is used to manage content, databases, sessions, and build e-commerce sites. PHP is free, efficient, and runs on many platforms. It supports popular databases like MySQL and protocols like HTTP. Key advantages of PHP include performance, portability, ease of use, open source nature, and large community support.
The document provides an overview of PHP (Hypertext Preprocessor), which is a widely used open-source scripting language used for web development. PHP code is executed on the server and generates HTML that is sent to the browser. PHP can connect to databases, collect form data, send/receive cookies, and more. It runs on many platforms and servers and is easy to learn. The document also covers basic PHP syntax, comments, variables, variable scope, and how to use global and static variables.
This document provides an introduction to PHP, covering topics such as what PHP is, how to set up a PHP development environment, PHP syntax, variables, data types, conditional statements, loops, and arrays. Some key points covered include:
- PHP is a server-side scripting language commonly used for web development. It allows developers to add dynamic content and functionality to websites.
- PHP code is embedded within HTML and executed on the server before the page is sent to the browser.
- The document outlines PHP syntax, how to comment code, and introduces basic programming concepts like variables, data types, conditional statements and loops.
- Arrays allow storing and managing multiple values/elements under one variable
The document discusses HTML tags and PHP. It provides an introduction to PHP including what PHP is, how PHP files work, what PHP can do, and why PHP is useful. It also covers basic PHP syntax, variables, echo and print statements, and variable scope.
PHP is a server-side scripting language used for web development that is embedded into HTML code. It allows websites to be dynamic and interactive. PHP supports different variable scopes, data types, functions for strings, and more. Key features include using <?php ?> tags to embed PHP code, case-sensitive variables, and both scalar and compound data types.
Introduction of PHP with all the basic codes and tags. Explanation of all the confusing keywords. PHP forms are also explained along with operators and datatypes.
This document provides an overview of course units for a web technologies course. It discusses the following:
Unit I introduces PHP concepts like variables, data types, arrays, strings, operators, control structures, functions, forms, file uploads, database connectivity, sessions and cookies.
Unit II covers XML concepts such as tags, attributes, document type definition, XML schemas, DOM and SAX parsers.
Unit III discusses servlet concepts including the servlet lifecycle, API, packages, request and response handling, cookies, sessions, security and database connectivity using JDBC.
Unit IV focuses on JSP concepts like page anatomy, processing, declarations, directives, expressions, implicit objects, beans, cookies,
The document provides an introduction to PHP basics including:
- PHP code is embedded in HTML using tags and the server executes the PHP code and substitutes output into the HTML page.
- PHP supports variables, data types, operators, control structures like if/else statements and loops. Useful built-in functions allow working with forms, cookies, files, time and date.
- Server-side programming alternatives like CGI, ASP, Java Servlets, and PHP are discussed. PHP was created in 1995 and is now widely used as a free, open-source scripting language for server-side web development.
This document provides an overview of the PHP programming language. It discusses that PHP is a server-side scripting language used for building dynamic web applications. It can be used to collect form data, generate dynamic page content, create and manage files and databases on the server. The document then demonstrates basic PHP syntax and shows how to output text and variables to the browser. It also covers PHP data types like strings, integers, arrays and objects. Finally, it provides examples of common string manipulation functions in PHP.
PHP is a server-side scripting language commonly used for web development. It allows files containing text, HTML, and PHP scripts to be processed on the server and returned to the browser as plain HTML. PHP can generate dynamic page content, interact with databases, send and receive cookies, and more. Some key features of PHP include that it is free, open source, runs on most server environments, and can be easily learned. The document provides examples of basic PHP syntax, variables, data types, operators, and conditional statements.
PHP is a server-side scripting language that is widely used for web development. It allows developers to add dynamic content to websites. Some key points about PHP include:
- PHP code is executed on the server and generates HTML that is sent to the browser. It can connect to databases, collect form data, and generate dynamic webpage content.
- It supports common data types like strings, integers, floats, booleans, arrays and objects. It also has variables, constants, operators, and control structures to write programs.
- PHP files have a .php extension and can contain HTML, CSS, JavaScript and PHP code. The PHP code is parsed and executed by the server to produce output.
This document provides an overview of server-side technologies PHP. It begins with an introduction to PHP that describes what PHP is, what PHP files are, and what PHP can do. It then covers PHP features, syntax, variables, operators, conditions and loops, functions, string manipulation, and arrays. The document also includes sample code examples for each topic. It aims to teach the fundamentals of PHP for developing dynamic web applications.
PHP is a server-side scripting language commonly used for web development. It allows developers to add dynamic and interactive elements to websites. The document outlines what PHP is, how to install it, basic syntax rules, and common operations like variables, data types, functions for manipulating strings, and different types of operators.
PHP is a server-side scripting language commonly used for web development. It allows developers to add dynamic content and functionality to websites. PHP code is executed on the server and the results are sent to the browser. This document provides an introduction to key PHP concepts like variables, operators, functions, forms, and GET/POST requests.
The basics of php for engeneering studentsrahuljustin77
freeCodeCamp.org
Donate
Learn to code — free 3,000-hour curriculum
AUGUST 30, 2021
/
#PHP
What is PHP? The PHP Programming Language Meaning Explained
Kolade Chris
Kolade Chris
PHP is an open-source server-side scripting language that many devs use for web development. It is also a general-purpose language that you can use to make lots of projects, including Graphical User Interfaces (GUIs).
In this article, I will help you explore the world of PHP so you can learn how it works and its basic features. By the end, you will be able to write your first Hello World program in PHP.
What Does PHP Mean?
The abbreviation PHP initially stood for Personal Homepage. But now it is a recursive acronym for Hypertext Preprocessor. (It's recursive in the sense that the first word itself is an abbreviation, so the full meaning doesn't follow the abbreviation.)
The first version of PHP was launched 26 years ago. Now it's on version 8, released in November 2020, but version 7 remains the most widely used.
PHP runs on the Zend engine, which is the most popular implementation. There are some other implementations as well, like parrot, HPVM (Hip Hop Virtual Machine), and Hip Hop, created by Facebook.
PHP is mostly used for making web servers. It runs on the browser and is also capable of running in the command line. So, if you don't feel like showing your code output in the browser, you can show it in the terminal.
Advantages of PHP
PHP has some advantages that have made it so popular, and it's been the go-to language for web servers for more than 15 years now. Here are some of PHP's benefits:
Cross-Platform: PHP is platform-independent. You don't have to have a particular OS to use it because it runs on every platform, whether it's Mac, Windows, or Linux.
Open Source: PHP is open source. The original code is made available to everyone who wants to build upon it. This is one of the reasons why one of its frameworks, Laravel, is so popular.
Easy to learn: PHP is not hard to learn for absolute beginners. You can pick it up pretty if you already have programming knowledge.
PHP syncs with all Databases: You can easily connect PHP to all Databases, relational and non-relational. So it can connect in no time to MySQL, Postgress, MongoDB, or any other database.
Supportive Community: PHP has a very supportive online community. The official documentation provides guides on how to use the features and you can easily get your problem fixed while stuck.
Who Uses PHP
A number of established companies and tech giants use PHP to run their servers and make a lot of incredible things.
Facebook: Facebook uses PHP to power its site. In turn, the company contributed to the community by creating an implementation known as Hip Hop for PHP.
Wikipedia: one of the world's largest sources of information on any topic, Wikipedia is built in PHP.
Content Management Systems (CMSs): the world's most popular content management system, WordPress, is built in PHP. Other content managem
This document provides an introduction to PHP (Hypertext Preprocessor), which is a server-side scripting language used for web development. It discusses three-tiered websites, server-side scripting, and some key aspects of PHP including its history, basic syntax, variables, data types, functions, and conditional statements. PHP allows for dynamic content generation, computational processing, database access, and more on the server side to create interactive websites and web applications.
PHP is a widely-used open source scripting language used to make dynamic web pages. PHP code is executed on the server and returns HTML to display in the browser. PHP can connect to databases, validate and collect form data, and more. It runs on many platforms and servers and supports various databases. PHP code is written in files with a .php extension and can contain HTML, JavaScript, and PHP code. Variables and data types in PHP include strings, integers, floats, booleans, arrays, objects and NULL. PHP also uses operators, conditional and repetition control structures to control program flow.
This document provides an introduction to PHP and MySQL for educational purposes. It discusses PHP basics like syntax, variables, operators, control structures, and functions. It also covers server-side dynamic web programming approaches like CGI, ASP, Java Servlets and JSP. The document explains what PHP is, how it works, and what is needed to use it. It provides examples of PHP code for scalars, operators, control structures, arrays and date functions. The goal is to provide basic PHP knowledge and code examples but not teach everything about PHP.
Hypertext Preprocessor Originally called “Personal Home Page Tools” Popular server-side scripting technology Open-source Anyone may view, modify and redistribute source code Supported freely by community Platform independent
PHP is a server-side scripting language used for web development. It allows developers to add dynamic content and functionality to websites. Some key points about PHP from the document:
- PHP code is embedded into HTML and executed on the server to create dynamic web page content. It can be used to connect to databases, process forms, and more.
- PHP has many data types including strings, integers, floats, booleans, arrays, objects, null values and resources. Variables, operators, and conditional statements allow for control flow and data manipulation.
- Common PHP structures include if/else statements for conditional logic, loops like for/while/foreach for iteration, and functions for reusability. Ar
The document provides an introduction to PHP including:
- PHP basics like syntax, variables, operators, control structures
- How to work with forms, cookies, files, dates
- Creating functions
- Displaying dates in different formats
- Using arrays
- Server-side scripting alternatives like ASP, Java Servlets
- The goal is to provide enough knowledge to get started with PHP but not teach everything about it.
This document provides an introduction to PHP (Personal Home Page Hypertext Preprocessor), which is a server-side scripting language designed for web development. It discusses key features of PHP including its open source nature, speed of development, performance, and portability. The document also provides examples of basic PHP syntax and how to work with variables, data types, operators, conditional statements, and loops.
The document provides an introduction to PHP basics including:
- PHP code is embedded in HTML using tags and the server executes the PHP code and substitutes output into the HTML page.
- PHP supports variables, data types, operators, control structures like if/else statements and loops. Useful built-in functions allow working with forms, cookies, files, time and date.
- Server-side programming alternatives like CGI, ASP, Java Servlets, and PHP are discussed. PHP was created in 1995 and is now widely used as a free, open-source scripting language for server-side web development.
This document provides an overview of the PHP programming language. It discusses that PHP is a server-side scripting language used for building dynamic web applications. It can be used to collect form data, generate dynamic page content, create and manage files and databases on the server. The document then demonstrates basic PHP syntax and shows how to output text and variables to the browser. It also covers PHP data types like strings, integers, arrays and objects. Finally, it provides examples of common string manipulation functions in PHP.
PHP is a server-side scripting language commonly used for web development. It allows files containing text, HTML, and PHP scripts to be processed on the server and returned to the browser as plain HTML. PHP can generate dynamic page content, interact with databases, send and receive cookies, and more. Some key features of PHP include that it is free, open source, runs on most server environments, and can be easily learned. The document provides examples of basic PHP syntax, variables, data types, operators, and conditional statements.
PHP is a server-side scripting language that is widely used for web development. It allows developers to add dynamic content to websites. Some key points about PHP include:
- PHP code is executed on the server and generates HTML that is sent to the browser. It can connect to databases, collect form data, and generate dynamic webpage content.
- It supports common data types like strings, integers, floats, booleans, arrays and objects. It also has variables, constants, operators, and control structures to write programs.
- PHP files have a .php extension and can contain HTML, CSS, JavaScript and PHP code. The PHP code is parsed and executed by the server to produce output.
This document provides an overview of server-side technologies PHP. It begins with an introduction to PHP that describes what PHP is, what PHP files are, and what PHP can do. It then covers PHP features, syntax, variables, operators, conditions and loops, functions, string manipulation, and arrays. The document also includes sample code examples for each topic. It aims to teach the fundamentals of PHP for developing dynamic web applications.
PHP is a server-side scripting language commonly used for web development. It allows developers to add dynamic and interactive elements to websites. The document outlines what PHP is, how to install it, basic syntax rules, and common operations like variables, data types, functions for manipulating strings, and different types of operators.
PHP is a server-side scripting language commonly used for web development. It allows developers to add dynamic content and functionality to websites. PHP code is executed on the server and the results are sent to the browser. This document provides an introduction to key PHP concepts like variables, operators, functions, forms, and GET/POST requests.
The basics of php for engeneering studentsrahuljustin77
freeCodeCamp.org
Donate
Learn to code — free 3,000-hour curriculum
AUGUST 30, 2021
/
#PHP
What is PHP? The PHP Programming Language Meaning Explained
Kolade Chris
Kolade Chris
PHP is an open-source server-side scripting language that many devs use for web development. It is also a general-purpose language that you can use to make lots of projects, including Graphical User Interfaces (GUIs).
In this article, I will help you explore the world of PHP so you can learn how it works and its basic features. By the end, you will be able to write your first Hello World program in PHP.
What Does PHP Mean?
The abbreviation PHP initially stood for Personal Homepage. But now it is a recursive acronym for Hypertext Preprocessor. (It's recursive in the sense that the first word itself is an abbreviation, so the full meaning doesn't follow the abbreviation.)
The first version of PHP was launched 26 years ago. Now it's on version 8, released in November 2020, but version 7 remains the most widely used.
PHP runs on the Zend engine, which is the most popular implementation. There are some other implementations as well, like parrot, HPVM (Hip Hop Virtual Machine), and Hip Hop, created by Facebook.
PHP is mostly used for making web servers. It runs on the browser and is also capable of running in the command line. So, if you don't feel like showing your code output in the browser, you can show it in the terminal.
Advantages of PHP
PHP has some advantages that have made it so popular, and it's been the go-to language for web servers for more than 15 years now. Here are some of PHP's benefits:
Cross-Platform: PHP is platform-independent. You don't have to have a particular OS to use it because it runs on every platform, whether it's Mac, Windows, or Linux.
Open Source: PHP is open source. The original code is made available to everyone who wants to build upon it. This is one of the reasons why one of its frameworks, Laravel, is so popular.
Easy to learn: PHP is not hard to learn for absolute beginners. You can pick it up pretty if you already have programming knowledge.
PHP syncs with all Databases: You can easily connect PHP to all Databases, relational and non-relational. So it can connect in no time to MySQL, Postgress, MongoDB, or any other database.
Supportive Community: PHP has a very supportive online community. The official documentation provides guides on how to use the features and you can easily get your problem fixed while stuck.
Who Uses PHP
A number of established companies and tech giants use PHP to run their servers and make a lot of incredible things.
Facebook: Facebook uses PHP to power its site. In turn, the company contributed to the community by creating an implementation known as Hip Hop for PHP.
Wikipedia: one of the world's largest sources of information on any topic, Wikipedia is built in PHP.
Content Management Systems (CMSs): the world's most popular content management system, WordPress, is built in PHP. Other content managem
This document provides an introduction to PHP (Hypertext Preprocessor), which is a server-side scripting language used for web development. It discusses three-tiered websites, server-side scripting, and some key aspects of PHP including its history, basic syntax, variables, data types, functions, and conditional statements. PHP allows for dynamic content generation, computational processing, database access, and more on the server side to create interactive websites and web applications.
PHP is a widely-used open source scripting language used to make dynamic web pages. PHP code is executed on the server and returns HTML to display in the browser. PHP can connect to databases, validate and collect form data, and more. It runs on many platforms and servers and supports various databases. PHP code is written in files with a .php extension and can contain HTML, JavaScript, and PHP code. Variables and data types in PHP include strings, integers, floats, booleans, arrays, objects and NULL. PHP also uses operators, conditional and repetition control structures to control program flow.
This document provides an introduction to PHP and MySQL for educational purposes. It discusses PHP basics like syntax, variables, operators, control structures, and functions. It also covers server-side dynamic web programming approaches like CGI, ASP, Java Servlets and JSP. The document explains what PHP is, how it works, and what is needed to use it. It provides examples of PHP code for scalars, operators, control structures, arrays and date functions. The goal is to provide basic PHP knowledge and code examples but not teach everything about PHP.
Hypertext Preprocessor Originally called “Personal Home Page Tools” Popular server-side scripting technology Open-source Anyone may view, modify and redistribute source code Supported freely by community Platform independent
PHP is a server-side scripting language used for web development. It allows developers to add dynamic content and functionality to websites. Some key points about PHP from the document:
- PHP code is embedded into HTML and executed on the server to create dynamic web page content. It can be used to connect to databases, process forms, and more.
- PHP has many data types including strings, integers, floats, booleans, arrays, objects, null values and resources. Variables, operators, and conditional statements allow for control flow and data manipulation.
- Common PHP structures include if/else statements for conditional logic, loops like for/while/foreach for iteration, and functions for reusability. Ar
The document provides an introduction to PHP including:
- PHP basics like syntax, variables, operators, control structures
- How to work with forms, cookies, files, dates
- Creating functions
- Displaying dates in different formats
- Using arrays
- Server-side scripting alternatives like ASP, Java Servlets
- The goal is to provide enough knowledge to get started with PHP but not teach everything about it.
This document provides an introduction to PHP (Personal Home Page Hypertext Preprocessor), which is a server-side scripting language designed for web development. It discusses key features of PHP including its open source nature, speed of development, performance, and portability. The document also provides examples of basic PHP syntax and how to work with variables, data types, operators, conditional statements, and loops.
This document provides information about the Fifth edition of the magazine "Sthapatya" published by the Association of Civil Engineers (Practicing) Aurangabad. It includes messages from current and past presidents of ACEP, memories and photos from past ACEP events, information on life time achievement awards given by ACEP, and a technical article on concrete maintenance, repairs and strengthening. The document highlights activities of ACEP and provides a technical educational article for members.
First Review PPT gfinal gyft ftu liu yrfut goSowndarya6
CyberShieldX provides end-to-end security solutions, including vulnerability assessment, penetration testing, and real-time threat detection for business websites. It ensures that organizations can identify and mitigate security risks before exploitation.
Unlike traditional security tools, CyberShieldX integrates AI models to automate vulnerability detection, minimize false positives, and enhance threat intelligence. This reduces manual effort and improves security accuracy.
Many small and medium businesses lack dedicated cybersecurity teams. CyberShieldX provides an easy-to-use platform with AI-powered insights to assist non-experts in securing their websites.
Traditional enterprise security solutions are often expensive. CyberShieldX, as a SaaS platform, offers cost-effective security solutions with flexible pricing for businesses of all sizes.
Businesses must comply with security regulations, and failure to do so can result in fines or data breaches. CyberShieldX helps organizations meet compliance requirements efficiently.
本資料「To CoT or not to CoT?」では、大規模言語モデルにおけるChain of Thought(CoT)プロンプトの効果について詳しく解説しています。
CoTはあらゆるタスクに効く万能な手法ではなく、特に数学的・論理的・アルゴリズム的な推論を伴う課題で高い効果を発揮することが実験から示されています。
一方で、常識や一般知識を問う問題に対しては効果が限定的であることも明らかになりました。
複雑な問題を段階的に分解・実行する「計画と実行」のプロセスにおいて、CoTの強みが活かされる点も注目ポイントです。
This presentation explores when Chain of Thought (CoT) prompting is truly effective in large language models.
The findings show that CoT significantly improves performance on tasks involving mathematical or logical reasoning, while its impact is limited on general knowledge or commonsense tasks.
Rearchitecturing a 9-year-old legacy Laravel application.pdfTakumi Amitani
An initiative to re-architect a Laravel legacy application that had been running for 9 years using the following approaches, with the goal of improving the system’s modifiability:
・Event Storming
・Use Case Driven Object Modeling
・Domain Driven Design
・Modular Monolith
・Clean Architecture
This slide was used in PHPxTKY June 2025.
https://phpxtky.connpass.com/event/352685/
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...ijscai
International Journal on Soft Computing, Artificial Intelligence and Applications (IJSCAI) is an open access peer-reviewed journal that provides an excellent international forum for sharing knowledge and results in theory, methodology and applications of Artificial Intelligence, Soft Computing. The Journal looks for significant contributions to all major fields of the Artificial Intelligence, Soft Computing in theoretical and practical aspects. The aim of the Journal is to provide a platform to the researchers and practitioners from both academia as well as industry to meet and share cutting-edge development in the field.
A SEW-EURODRIVE brake repair kit is needed for maintenance and repair of specific SEW-EURODRIVE brake models, like the BE series. It includes all necessary parts for preventative maintenance and repairs. This ensures proper brake functionality and extends the lifespan of the brake system
PREDICTION OF ROOM TEMPERATURE SIDEEFFECT DUE TOFAST DEMAND RESPONSEFOR BUILD...ijccmsjournal
In order to evaluate side-effect of power limitation due to the Fast Automated Demand Response
(FastADR) for building air-conditioning facilities, a prediction model on short time change of average
room temperature has been developed. A room temperature indexis defined as a weighted average of the
entire building for room temperature deviations from the setpoints. The index is assumed to be used to
divide total FastADRrequest to distribute power limitation commands to each building.In order to predict
five-minute-change of the index, our combined mathematical model of an auto regression (AR) and a
neural network (NN) is proposed.In the experimental results, the combined model showedthe root mean
square error (RMSE) of 0.23 degrees, in comparison with 0.37 and 0.26 for conventional single NN and AR
models, respectively. This result is satisfactory prediction for required comfort of approximately 1 degree
Celsius allowance.
2. Introduction
• PHP is an acronym for "PHP: Hypertext Preprocessor"
• PHP is a widely-used, open source scripting language
• PHP scripts are executed on the server
• PHP is free to download and use
• PHP files can contain text, HTML, CSS, JavaScript, and
PHP code
• PHP code is executed on the server, and the result is
returned to the browser as plain HTML
• PHP files have extension ".php"
3. Introduction(Contd.,)
• PHP can generate dynamic page content
• PHP can create, open, read, write, delete, and close
files on the server
• PHP can collect form data
• PHP can send and receive cookies
• PHP can add, delete, modify data in your database
• PHP can be used to control user-access
• PHP can encrypt data
• With PHP you are not limited to output HTML.
• You can output images or PDF files. You can also output
any text, such as XHTML and XML.
4. Why?
• PHP runs on various platforms (Windows,
Linux, Unix, Mac OS X, etc.)
• PHP is compatible with almost all servers used
today (Apache, IIS, etc.)
• PHP supports a wide range of databases
• PHP is free. Download it from the official PHP
resource: www.php.net
• PHP is easy to learn and runs efficiently on the
server side
5. What’s New in PHP?
• PHP 7 is much faster than the previous
popular stable release (PHP 5.6)
• PHP 7 has improved Error Handling
• PHP 7 supports stricter Type Declarations for
function arguments
• PHP 7 supports new operators (like the
spaceship operator: <=>)
6. Set Up PHP on Your Own PC
• However, if your server does not support PHP,
you must:
• install a web server
• install PHP
• install a database, such as MySQL
• The official PHP website (PHP.net) has installation
instructions for
PHP: http://php.net/manual/en/install.php
•
7. Basic PHP Syntax
• A PHP script is executed on the server, and the
plain HTML result is sent back to the browser.
• <?php
// PHP code goes here
?>
• The default file extension for PHP files is
".php".
• A PHP file normally contains HTML tags, and
some PHP scripting code.
9. PHP Case Sensitivity
• In PHP, keywords (e.g. if, else, while, echo, etc.), classes, functions,
and user-defined functions are not case-sensitive.
• In the example below, all three echo statements below are equal
and legal:
• <!DOCTYPE html>
<html>
<body>
<?php
ECHO "Hello World!<br>";
echo "Hello World!<br>";
EcHo "Hello World!<br>";
?>
</body>
</html>
10. • Look at the example below; only the first statement
will display the value of the $color variable! This is
because $color, $COLOR, and $coLOR are treated as
three different variables:
• <!DOCTYPE html>
<html>
<body>
<?php
$color = "red";
echo "My car is " . $color . "<br>";
echo "My house is " . $COLOR . "<br>";
echo "My boat is " . $coLOR . "<br>";
?>
</body>
</html>
11. Comments in PHP
• <!DOCTYPE html>
<html>
<body>
<?php
// This is a single-line comment
# This is also a single-line comment
/*
This is a multiple-lines comment block
that spans over multiple
lines
*/
?>
</body>
</html>
12. Creating (Declaring) PHP Variables
• In PHP, a variable starts with the $ sign,
followed by the name of the variable:
• <?php
$txt = "Hello world!";
$x = 5;
$y = 10.5;
?>
13. PHP Variables
Rules for PHP variables:
• A variable starts with the $ sign, followed by the
name of the variable
• A variable name must start with a letter or the
underscore character
• A variable name cannot start with a number
• A variable name can only contain alpha-numeric
characters and underscores (A-z, 0-9, and _ )
• Variable names are case-sensitive
($age and $AGE are two different variables)
14. Example
• <?php
$txt = “Universe";
echo "I love $txt!";
?>
• <?php
$txt = “Universe";
echo "I love " . $txt . "!";
?>
15. PHP is a Loosely Typed Language
• In the example above, notice that we did not
have to tell PHP which data type the variable is.
• PHP automatically associates a data type to the
variable, depending on its value. Since the data
types are not set in a strict sense, you can do
things like adding a string to an integer without
causing an error.
• In PHP 7, type declarations were added. This
gives an option to specify the data type expected
when declaring a function, and by enabling the
strict requirement, it will throw a "Fatal Error" on
a type mismatch.
16. PHP Variables Scope
• The scope of a variable is the part of the script
where the variable can be referenced/used.
• PHP has three different variable scopes:
• local
• global
• static
17. Global and Local Scope
• A variable declared outside a function has a
GLOBAL SCOPE and can only be accessed outside
a function:
• <?php
$x = 5; // global scope
function myTest() {
// using x inside this function will generate an
error
echo "<p>Variable x inside function is: $x</p>";
}
myTest();
echo "<p>Variable x outside function is: $x</p>";
?>
Output:
Variable x inside function is:
Variable x outside function is: 5
18. Variable with local scope:
• <?php
function myTest() {
$x = 5; // local scope
echo "<p>Variable x inside function is: $x</p>";
}
myTest();
// using x outside the function will generate an
error
echo "<p>Variable x outside function is: $x</p>";
?>
Output:
Variable x inside function is: 5
Variable x outside function is:
19. PHP echo and print Statements
• echo and print are more or less the same. They
are both used to output data to the screen.
• The differences are small: echo has no return
value while print has a return value of 1 so it can
be used in expressions.
• echo can take multiple parameters (although
such usage is rare) while print can take one
argument.
• echo is marginally faster than print.
20. Examples
<!DOCTYPE html>
<html>
<body>
<?php
echo "<h2>PHP is Fun!</h2>";
echo "Hello world!<br>";
echo "I'm about to learn PHP!<br>";
echo "This ", "string ", "was ", "made ", "with multiple parameters.";
?>
</body>
</html>
Output:
PHP is Fun!
Hello world!
I'm about to learn PHP!
This string was made with multiple
parameters.
21. Examples
<?php
$txt1 = "Learn PHP";
$txt2 = “Its easy to learn";
$x = 5;
$y = 4;
echo "<h2>" . $txt1 . "</h2>";
echo "Study PHP at " . $txt2 . "<br>";
echo $x + $y;
?>
Output:
Study PHP at Its easy to learn
9
23. PHP Data Types
PHP supports the following data types:
• String
• Integer
• Float (floating point numbers - also called double)
• Boolean
• Array
• Object
• NULL
• Resource
24. PHP String
• A string is a sequence of characters, like "Hello
world!".
• A string can be any text inside quotes. You can
use single or double quotes:
<?php
$x = "Hello world!";
$y = 'Hello world!';
echo $x;
echo "<br>";
echo $y;
?>
25. PHP Integer
• 2, 256, -256, 10358, -179567 are all integers.
• An integer is a number without any decimal part.
• An integer data type is a non-decimal number
between -2147483648 and 2147483647 in 32 bit
systems, and between -9223372036854775808
and 9223372036854775807 in 64 bit systems.
• A value greater (or lower) than this, will be stored
as float, because it exceeds the limit of an integer.
• Note: Another important thing to know is that
even if 4 * 2.5 is 10, the result is stored as float,
because one of the operands is a float (2.5).
26. • Here are some rules for integers:
• An integer must have at least one digit
• An integer must NOT have a decimal point
• An integer can be either positive or negative
• Integers can be specified in three formats:
decimal (10-based), hexadecimal (16-based -
prefixed with 0x) or octal (8-based - prefixed
with 0)
27. • PHP has the following predefined constants
for integers:
• PHP_INT_MAX - The largest integer supported
• PHP_INT_MIN - The smallest integer
supported
• PHP_INT_SIZE - The size of an integer in bytes
28. • PHP has the following functions to check if the
type of a variable is integer:
• is_int()
• is_integer() - alias of is_int()
• is_long() - alias of is_int()
29. Example
<!DOCTYPE html>
<html>
<body>
<?php
// Check if the type of a variable is integer
$x = 5985;
var_dump(is_int($x));
echo "<br>";
// Check again...
$x = 59.85;
var_dump(is_int($x));
?>
</body>
</html>
Output:
bool(true)
bool(false)