PHP is a server-side scripting language used for web development that allows developers to create dynamic web pages. Some key points:
- PHP scripts are executed on the server and can contain HTML tags, text, and PHP code.
- PHP can connect to databases like MySQL and supports features like forms, sessions, cookies, and functions.
- Common control structures include if/else statements and while loops. Functions must be defined before use.
- To interact with databases, a connection is made, a database is selected, queries are performed, results are processed, and the connection is closed.
PHP stands for “PHP: Hypertext Preprocessor”. It is very good for creating dynamic content. PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.
PHP stands for “PHP: Hypertext Preprocessor”. It is very good for creating dynamic content. PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.
The PHP is a powerful web scripting language that is free and efficient language for building dynamic web pages. This presentation is an introduction to the basics of PHP programming with a little sample program.
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 complete reference with database concepts for beginners is generally useful for those who want to start the career as a php developer. given each and every information right from the scratch to understand for the beginners and students as well. I hope this will help you a lot for the beginners to start the career.
PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language. As of January 2013, PHP was installed on more than 240 million websites (39% of those sampled) and 2.1 million web servers.[4] Originally created by Rasmus Lerdorf in 1994,[5] the reference implementation of PHP (powered by the Zend Engine) is now produced by The PHP Group.[6] While PHP originally stood for Personal Home Page,[5] it now stands for PHP: Hypertext Preprocessor, which is a recursive backronym
Brief History of PHP
PHP (PHP: Hypertext Preprocessor) was created by Rasmus Lerdorf in 1994. It was initially developed for HTTP usage logging and server-side form generation in Unix.
PHP 2 (1995) transformed the language into a Server-side embedded scripting language. Added database support, file uploads, variables, arrays, recursive functions, conditionals, iteration, regular expressions, etc.
PHP 3 (1998) added support for ODBC data sources, multiple platform support, email protocols (SNMP,IMAP), and new parser written by Zeev Suraski and Andi Gutmans .
PHP 4 (2000) became an independent component of the web server for added efficiency. The parser was renamed the Zend Engine. Many security features were added.
PHP 5 (2004) adds Zend Engine II with object oriented programming, robust XML support using the libxml2 library, SOAP extension for interoperability with Web Services, SQLite has been bundled with PHP
What is PHP Used For?
PHP is a general-purpose server-side scripting language originally designed for web development to produce dynamic web pages
PHP can interact with MySQL databases
What is PHP?
PHP == ‘Hypertext Preprocessor’
Open-source, server-side scripting language
Used to generate dynamic web-pages
PHP scripts reside between reserved PHP tags
This allows the programmer to embed PHP scripts within HTML pages
What is PHP (cont’d)
Interpreted language, scripts are parsed at run-time rather than compiled beforehand
Executed on the server-side
Source-code not visible by client
‘View Source’ in browsers does not display the PHP code
Various built-in functions allow for fast development
Compatible with many popular databases
What does PHP code look like?
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
Comments in PHP
Standard C, C++, and shell comment symbols
Variables in PHP
PHP variables must begin with a “$” sign
Case-sensitive ($Foo != $foo != $fOo)
Global and locally-scoped variables
Global variables can be used anywhere
Local variables restricted to a function or class
Certain variable names reserved by PHP
Form variables ($_POST, $_GET)
Server variables ($_SERVER)
Etc.
Variable usage
Arithmetic Operations
$a - $b // subtraction
$a * $b // multiplication
$a / $b // division
$a += 5 // $a = $a+5 Also works for *= and /=
Concatenation
Use a period to join strings into one.
If ... Else...
If (condition)
{
Statements;
}
Else
{
Statement;
}
While Loops
While (condition)
{
Statements;
}
Date Display
$datedisplay=date(“yyyy/m/d”);
Print $datedisplay;
# If the date is April 1st, 2009
# It would display as 2009/4/1
Month, Day & Date Format Symbols
The PHP is a powerful web scripting language that is free and efficient language for building dynamic web pages. This presentation is an introduction to the basics of PHP programming with a little sample program.
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 complete reference with database concepts for beginners is generally useful for those who want to start the career as a php developer. given each and every information right from the scratch to understand for the beginners and students as well. I hope this will help you a lot for the beginners to start the career.
PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language. As of January 2013, PHP was installed on more than 240 million websites (39% of those sampled) and 2.1 million web servers.[4] Originally created by Rasmus Lerdorf in 1994,[5] the reference implementation of PHP (powered by the Zend Engine) is now produced by The PHP Group.[6] While PHP originally stood for Personal Home Page,[5] it now stands for PHP: Hypertext Preprocessor, which is a recursive backronym
Brief History of PHP
PHP (PHP: Hypertext Preprocessor) was created by Rasmus Lerdorf in 1994. It was initially developed for HTTP usage logging and server-side form generation in Unix.
PHP 2 (1995) transformed the language into a Server-side embedded scripting language. Added database support, file uploads, variables, arrays, recursive functions, conditionals, iteration, regular expressions, etc.
PHP 3 (1998) added support for ODBC data sources, multiple platform support, email protocols (SNMP,IMAP), and new parser written by Zeev Suraski and Andi Gutmans .
PHP 4 (2000) became an independent component of the web server for added efficiency. The parser was renamed the Zend Engine. Many security features were added.
PHP 5 (2004) adds Zend Engine II with object oriented programming, robust XML support using the libxml2 library, SOAP extension for interoperability with Web Services, SQLite has been bundled with PHP
What is PHP Used For?
PHP is a general-purpose server-side scripting language originally designed for web development to produce dynamic web pages
PHP can interact with MySQL databases
What is PHP?
PHP == ‘Hypertext Preprocessor’
Open-source, server-side scripting language
Used to generate dynamic web-pages
PHP scripts reside between reserved PHP tags
This allows the programmer to embed PHP scripts within HTML pages
What is PHP (cont’d)
Interpreted language, scripts are parsed at run-time rather than compiled beforehand
Executed on the server-side
Source-code not visible by client
‘View Source’ in browsers does not display the PHP code
Various built-in functions allow for fast development
Compatible with many popular databases
What does PHP code look like?
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
Comments in PHP
Standard C, C++, and shell comment symbols
Variables in PHP
PHP variables must begin with a “$” sign
Case-sensitive ($Foo != $foo != $fOo)
Global and locally-scoped variables
Global variables can be used anywhere
Local variables restricted to a function or class
Certain variable names reserved by PHP
Form variables ($_POST, $_GET)
Server variables ($_SERVER)
Etc.
Variable usage
Arithmetic Operations
$a - $b // subtraction
$a * $b // multiplication
$a / $b // division
$a += 5 // $a = $a+5 Also works for *= and /=
Concatenation
Use a period to join strings into one.
If ... Else...
If (condition)
{
Statements;
}
Else
{
Statement;
}
While Loops
While (condition)
{
Statements;
}
Date Display
$datedisplay=date(“yyyy/m/d”);
Print $datedisplay;
# If the date is April 1st, 2009
# It would display as 2009/4/1
Month, Day & Date Format Symbols
Vibrant Technologies is headquarted in Mumbai,India.We are the best php training provider in Navi Mumbai who provides Live Projects to students.We provide Corporate Training also.We are Best php classes in Mumbai according to our students and corporators
Custom, in depth 5 day PHP course I put together in 2014. I'm available to deliver this training in person at your offices - contact me at rich@quicloud.com for rate quotes.
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 mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...anshkhurana01
php-mysql classes in navi-mumbai,php-mysql course-provider-in-navi-mumbai,best php-mysql class in navi-mumbai
B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173 enquiry@vibrantgroup.co.in
PHP / MySQL applications are compatible to all operating systems, support all the popular databases, 100% remotely configurable, perfect for web programming & provide higher performance and speed.
PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly.
MySQL is a Relational Database Management System (RDBMS) that uses Structured Query Language (SQL).
PHP is the most popular scripting language for web development. It is free, open source and server-side (the code is executed on the server).
PHP third party tool and plug-in integration such as chat, forum, blog and search engine
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
2. IntroductionIntroduction
PHP is stands for ’Hypertext Preprocessor ’ used for making
dynamic web pages and interactive web pages.
PHP is server side scripting language intented to help web
developers build dynamic web pages.
PHP scripts are executed on the server.
PHP supports many databases (MySql ,Oracle,PostgreSQL,Generic
ODBC etc).
PHP was created by Rasmus Lerdrof in 1995.
PHP originally stood for ”PERSONAL HOME PAGE”
PHP is an Open Source software.
PHP is free to download and use.
3. PHP FilesPHP Files
PHP files can contain text, HTML Tags and scripts.
PHP files are returned to the browser as plain HTML
PHP files have a file extension of ”.php”.
EXECUTION OF PHP PAGE
4. “PHP is an HTML-embedded scripting language. Much of its syntax is
borrowed from C,Java & Perl with a couple of unique PHP-specific
features thrown in .The goal of the language is to allow web developers
to write dynamically generated pages quickly. ”
5. Brief History of PHPBrief History of PHP
PHP (PHP: Hypertext Preprocessor) was created by Rasmus Lerdorf
in 1994. It was initially developed for HTTP usage logging and server-
side form generation in Unix
PHP 2 (1995) transformed the language into a Server-side embedded
scripting language. Added database support, file uploads, variables,
arrays, recursive functions, conditionals, iteration, regular
expressions, etc.
PHP 3 (1998) added support for ODBC data sources, multiple
platform support, email protocols (SNMP,IMAP), and new parser
written by Zeev Suraski and Andi Gutmans .
PHP 4 (2000) became an independent component of the web server
for added efficiency. The parser was renamed the Zend Engine. Many
security features were added.
6.
PHP 5 (2004) adds Zend Engine II with object oriented programming,
robust XML support using the libxml2 library, SOAP extension for
interoperability with Web Services, SQLite has been bundled with
PHP
7. PHP FeaturesPHP Features
Open source / Free software.
Cross Platform to develop, to deploy, and to use.
Power,Robust, Scalable.
Web development specific.
Can be Object Oriented.
It is faster to code and faster to execute.
Large, active developer community.
20 million websites
Support for PHP is free.
Great documentation in many language www.php.net/docs.php
8. Why use PHP ?Why use PHP ?
1. Easy to use
Code is embedded into HTML. The PHP code is enclosed in special
start and end tags that allow you to jump into and out.
<html>
<head>
<title>Example</title>
</head>
10. 2.Cross Platform
Run on almost any web server on several Operating Systems.
One of the strongest features is the wide range of supported databases.
• Web Server : Apache, Microsoft IIS , Netscape Enterprise Server.
• Operating Systems : Unix (Solaris,Linux),Mac OS, Window
NT/98/2000/XP/2003.
• Supported Databases : dBase,Empress,FilePro (read only),
Hyperware, IBM DB2,InformixIngress,Frontbase,MySql,ODBC,Oracle
etc.
11. 3. Cost Benefits
PHP is free. Open Source code means that the entire PHP community
will contribute towards bug fixes. There are several add-on technologies
(libraries) for PHP that are also free.
12. DatatypesDatatypes
PHP stores whole numbers in a platform-dependent range.
This range is typically that of 32-bit signed integers. Unsigned
integers are converted to signed values in certain situations.
Arrays can contain elements of any type that handle in PHP .
Including resources, objects, and even other arrays.
PHP also supports strings, which can be used with single quotes,
double quotes, or heredoc syntax.
13. What does PHP code look like?What does PHP code look like?
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
…
?>
14. Comments in PHPComments in PHP
Standard C, C++, and shell comment symbols
// C++ and Java-style comment
# Shell-style comments
/* C-style comments
These can span multiple lines
*/
15. Variables in PHPVariables in PHP
PHP variables must begin with a “$” sign
Case-sensitive ($Foo != $foo != $fOo)
Global and locally-scoped variables
-- Global variables can be used anywhere
-- Local variables restricted to a function or class
Certain variable names reserved by PHP
-- Form variables ($_POST, $_GET)
-- Server variables ($_SERVER)
-- Etc.
17. EchoEcho
The PHP command ‘echo’ is used to output the parameters passed
to it
--The typical usage for this is to send data to the client’s web-browser
Syntax
-- void echo (string arg1 [, string argn...])
-- In practice, arguments are not passed in parentheses since echo
is a language construct rather than an actual function
18. Echo exampleEcho example
PHP scripts are stored as human-readable source code and are compiled
on-the-fly to an internal format that can be executed by the PHP engine.
Code optimizers aim to reduce the runtime of the compiled code by reducing
its size and making other changes that can reduce the execution time with the
goal of improving performance.
<?php
$foo = 25; // Numerical
variable
$bar = “Hello”; // String variable
echo $bar; // Outputs Hello
echo $foo,$bar; // Outputs 25Hello
echo “5x5=”,$foo; // Outputs
5x5=25
echo “5x5=$foo”; // Outputs 5x5=25
echo ‘5x5=$foo’; // Outputs 5x5=$foo
?>
19. Arithmetic OperationsArithmetic Operations
$a - $b // subtraction
$a * $b // multiplication
$a / $b // division
$a += 5 // $a = $a+5 Also works for *= and /=
<?php
$a=15;
$b=30;
$total=$a+$b;
Print $total;
Print “<p><h1>$total</h1>”;
// total is 45
?>
21. Escaping the CharacterEscaping the Character
If the string has a set of double quotation marks that must remain
visible, use the [backslash] before the quotation marks to ignore and
display them.
<?php
$heading=“”Computer Science””;
Print $heading;
?>
“Computer Science”
22. PHP Control StructuresPHP Control Structures
Control Structures: Are the structures within a language that allow us
to control the flow of execution through a program or script.
Grouped into conditional (branching) structures (e.g. if/else) and
repetition structures (e.g. while loops).
Example if/else if/else statement:
if ($foo == 0) {
echo ‘The variable foo is equal to 0’;
}
else if (($foo > 0) && ($foo <= 5)) {
echo ‘The variable foo is between 1 and 5’;
}
else {
echo ‘The variable foo is equal to ‘.$foo;
}
23. If ... Else...If ... Else...
If (condition)
{
Statements;
}
Else
{
Statement;
}
<?php
If($user==“John”)
{
Print “Hello John.”;
}
Else
{
Print “You are not John.”;
}
?>
No THEN in PHP
25. Date DisplayDate Display
$datedisplay=date(“yyyy/m/d”);
Print $datedisplay;
# If the date is April 1st
, 2009
# It would display as 2009/4/1
$datedisplay=date(“l, F m, Y”);
Print $datedisplay;
# If the date is April 1st
, 2009
# Wednesday, April 1, 2009
2009/4/1
Wednesday, April 1, 2009
26. Month, Day & Date Format SymbolsMonth, Day & Date Format Symbols
M Jan
F January
m 01
n 1
Day of Month d 01
Day of Month J 1
Day of Week l Monday
Day of Week D Mon
27. FunctionsFunctions
Functions MUST be defined before then can be called
Function headers are of the format
-- Note that no return type is specified
Unlike variables, function names are not case sensitive (foo(…) ==
Foo(…) == FoO(…))
function functionName($arg_1, $arg_2, …, $arg_n)
28. Functions exampleFunctions example
<?php
// This is a function
function foo($arg_1, $arg_2)
{
$arg_2 = $arg_1 * $arg_2;
return $arg_2;
}
$result_1 = foo(12, 3); //
Store the function
echo $result_1; // Outputs 36
echo foo(12, 3); // Outputs 36
?>
30. PHP FormsPHP Forms
Access to the HTTP POST and GET data is simple in PHPAccess to the HTTP POST and GET data is simple in PHP
The global variables $_POST[] and $_GET[] contain the request dataThe global variables $_POST[] and $_GET[] contain the request data
<?php
if ($_POST["submit"])
echo "<h2>You clicked Submit!</h2>";
else if ($_POST["cancel"])
echo "<h2>You clicked Cancel!</h2>";
?>
<form action="form.php" method="post">
<input type="submit" name="submit" value="Submit">
<input type="submit" name="cancel" value="Cancel">
</form>
31. What is a cookie ?What is a cookie ?
A cookie is a small file that the server embeds on the user's
computer. Each time the same computer requests for a page
with a browser, it will send the cookie too. With PHP, you can
both create and retrieve cookie values.
32. How To Create a Cookie?How To Create a Cookie?
The setcookie() function is used to create cookies.
Note: The setcookie() function must appear BEFORE the
<html> tag.
setcookie(name, [value], [expire], [path], [domain], [secure]);
This sets a cookie named "uname" - that expires after ten hours.
<?php setcookie("uname", $name, time()+36000); ?>
<html> <body> …
33. How To Retrieve a Cookie Value?How To Retrieve a Cookie Value?
To access a cookie you just refer to the cookie name as a
variable or use $_COOKIE array
Tip: Use the isset() function to find out if a cookie has been
set.
<html> <body>
<?php
if (isset($uname))
echo "Welcome " . $uname . "!<br />";
else
echo "You are not logged in!<br />"; ?>
</body> </html>
34. How To Delete a Cookie ?How To Delete a Cookie ?
Cookies must be deleted with the same parameters as they
were set with. If the value argument is an empty string (""),
and all other arguments match a previous call to setcookie,
then the cookie with the specified name will be deleted from
the remote client.
35. What is a Session?
The session support allows you to register arbitrary numbers
of variables to be preserved across requests.
A visitor accessing your web site is assigned an unique id,
the so-called session id. This is either stored in a cookie on
the user side or is propagated in the URL.
Tip: Use the isset() function to find out if a cookie has been
set.
36. How to Create a Session ?
The session_start() function is used to create cookies.
<?php
session_start();
?>
37. How to Retrieve a Session Value ?
Register Session variable
-- session_register('var1','var2',...); // will also create a session
-- PS:Session variable will be created on using even if you will not
register it!
Use it
<?php
session_start();
if (!isset($_SESSION['count']))
$_SESSION['count'] = 0;
else
$_SESSION['count']++;
?>
38. Storing Session Data
The $_SESSION superglobal array can be
used to store any session data.
e.g.
$_SESSION[‘name’] = $name;
$_SESSION[‘age’] = $age;
39. Reading Session Data
Data is simply read back from the $_SESSION
superglobal array.
e.g.
$_SESSION[‘name’] = $name;
$_SESSION[‘age’] = $age;
40. How to Delete a Session Value ?
session_unregister(´varname´);
How to destroy a session:
session_destroy()
41. PHP DATABASE INTERACTION IN FIVE STEPS
1) Create the Connection
2) Select the Database
3) Perform Database Query
4) Use Returned Data (if any)
5) Close Connection
42. 1. Connect with MySQL RDBMS
mysql_connect($hostName, $userName, $password) or
die("Unable to connect to host $hostName");
43. 2. Connect with database
mysql_select_db($dbName) or die("Unable to select
database $dbName");
44. 3. Perform Database Query
Queries: Nearly all table interaction and management is done through
queries:
Basic information searches
$query = "SELECT FirstName, LastName, DOB, Gender FROM
Patients WHERE Gender = '$Gender‘ ORDER BY FirstName
DESC";
$Patients = mysql_query($SQL);
Editing, adding, and deleting records and tables
$query = "INSERT INTO Patients (FirstName, LastName)
VALUES('$firstName', '$lastName')";
$Patients = mysql_query($SQL);
45. 4. Process Results (if any)
• Many functions exist to work with database results
mysql_num_rows()
– Number of rows in the result set
– Useful for iterating over result set
mysql_fetch_array()
– Returns a result row as an array
– Can be associative or numeric or both (default)
– $row = mysql_fetch_array($query);
– $row[‘column name’] :: value comes from database row with specified
column name
46. Process Results Loop
• Easy loop for processing results:
$result = mysql_query($query;
$num_rows = mysql_num_rows($query);
for ($i=0; $i<$num_rows; $i++) {
$row = mysql_fetch_array($result);
// take action on database results here
}
47. 5. Closing Database Connection
• mysql_close()
– Closes database connection
– Only works for connections opened with mysql_connect()
– Connections opened with mysql_pconnect() ignore this call
– Often not necessary to call this, as connections created by
mysql_connect are closed at the end of the script anyway