This document discusses PHP functions and modularity. It explains why functions are used to organize code and avoid repetition. Built-in PHP functions are powerful, and custom functions can be created by defining them with the function keyword. Functions can take arguments, return values, and be called by reference. Variable scope is also covered, noting that function variables are usually isolated unless declared global. The document demonstrates including other files to split code into multiple files and check for function existence. Overall it provides an overview of functions and modularity in PHP.
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.
The document provides an introduction to PHP, explaining that it is a server-side scripting language used to generate HTML web pages. It discusses the differences between client-side and server-side scripting, with PHP being an example of server-side scripting. The summary also explains how to create basic PHP pages and covers some basic PHP syntax including variables, data types, operators, and control structures like if/else statements.
This document provides an introduction to PHP, including an overview of server-side scripting, the basic PHP syntax, variables, operators, control structures like conditional statements and loops, and how PHP code is processed. It explains what PHP is, how it is widely used for building dynamic websites, and the basic components needed to develop PHP applications including a web server, PHP, and a database.
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Muhamad Al Imran
This document provides an introduction to PHP, including an overview of server-side scripting, how PHP code is processed, basic PHP syntax, variables, operators, control structures like conditional statements and loops, and other key PHP concepts. It explains what PHP is, how it is used to create dynamic web content, and some of the basic building blocks needed to get started with PHP programming.
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Muhamad Al Imran
This document provides an introduction to PHP, including an overview of server-side scripting, how PHP code is processed, basic PHP syntax, variables, operators, control structures like conditional statements and loops, and other key PHP concepts. It explains what PHP is, how it is used to create dynamic web content, and some of the basic building blocks needed to get started with PHP programming.
PHP is a server-side scripting language commonly used for web development. The document provides an introduction to PHP including a brief history, how PHP scripts are parsed, variables, arrays, operators, control structures, and including external files. It discusses PHP's architecture and how scripts are executed on the server before being sent to the browser.
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.
The document provides an introduction to PHP, explaining that it is a server-side scripting language used to generate HTML web pages. It discusses the differences between client-side and server-side scripting, with PHP being an example of server-side scripting. The summary also explains how to create basic PHP pages and covers some basic PHP syntax including variables, data types, operators, and control structures like if/else statements.
This document provides an introduction to PHP, including an overview of server-side scripting, the basic PHP syntax, variables, operators, control structures like conditional statements and loops, and how PHP code is processed. It explains what PHP is, how it is widely used for building dynamic websites, and the basic components needed to develop PHP applications including a web server, PHP, and a database.
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Muhamad Al Imran
This document provides an introduction to PHP, including an overview of server-side scripting, how PHP code is processed, basic PHP syntax, variables, operators, control structures like conditional statements and loops, and other key PHP concepts. It explains what PHP is, how it is used to create dynamic web content, and some of the basic building blocks needed to get started with PHP programming.
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Muhamad Al Imran
This document provides an introduction to PHP, including an overview of server-side scripting, how PHP code is processed, basic PHP syntax, variables, operators, control structures like conditional statements and loops, and other key PHP concepts. It explains what PHP is, how it is used to create dynamic web content, and some of the basic building blocks needed to get started with PHP programming.
PHP is a server-side scripting language commonly used for web development. The document provides an introduction to PHP including a brief history, how PHP scripts are parsed, variables, arrays, operators, control structures, and including external files. It discusses PHP's architecture and how scripts are executed on the server before being sent to the browser.
PHP is a server-side scripting language commonly used for web development. It allows developers to add dynamic content to websites. Key points:
- PHP scripts are executed on the server and output HTML, JavaScript, or other code to browsers.
- PHP supports variables, arrays, functions, classes, and control structures like if/else statements.
- External data like from text files or databases can be easily incorporated into dynamic web pages using PHP.
- PHP files have a .php extension and PHP code is delimited by <?php ?> tags within HTML files or standalone PHP files.
PHP Basics is a presentation that introduces PHP. It discusses that PHP is a server-side scripting language used for building dynamic websites. It can be embedded into HTML. When a PHP file is requested, the server processes the PHP code and returns the output to the browser as HTML. The presentation covers PHP syntax, variables, data types, operators, functions, and conditional statements. It provides examples to illustrate basic PHP concepts and functionality.
PHP is a widely-used open source scripting language suited for web development. It allows embedding code into HTML pages to make them dynamic. PHP code is executed on the server and generates HTML that is sent to the client. Key features include using variables, conditional statements, loops, functions, and interacting with databases or external sources. The document provides an introduction to basic PHP syntax and constructs like variables, arrays, operators, control structures, and functions.
Practical tips for dealing with projects involving legacy code. Covers investigating past projects, static analysis of existing code, and methods for changing legacy code.
Presented at PHP Benelux '10
PHP is a server-side scripting language commonly used for web development. It allows developers to add dynamic content to websites. PHP code is embedded within HTML and executed on the server before the page is sent to the browser. The document provides an introduction and overview of PHP, covering its history, syntax based on Perl and C, how PHP scripts are parsed and executed, variables, arrays, operators, control structures like if/else and loops, functions to include external files, and how PHP can be used to retrieve and display external data.
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.
The document provides an overview and introduction to PHP including:
- PHP is a server-side scripting language used for web development. It was created by Rasmus Lerdorf in 1995.
- It discusses PHP basics like syntax, variables, strings, arrays, functions, and how to interact with forms and retrieve data from web pages.
- It also covers using PHP to communicate with backend databases and services to fetch and parse XML/JSON data.
This document provides an introduction to PHP, covering its history, parsing, variables, arrays, operators, functions, control structures, and use of external data files. PHP is an open-source server-side scripting language that was originally created in 1994 and is widely used for web development. It allows developers to embed code into HTML pages that is executed on the server to dynamically generate content.
This document provides an overview of PHP, its uses, installation, configuration, and basic concepts. It discusses that PHP is a widely used programming language for building dynamic websites. It can be installed along with Apache and MySQL on a server. The document also covers PHP variables, data types, flow control, functions, and how to work with strings and numbers.
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 is a server-side scripting language commonly used with the LAMP stack. It allows developers to easily create dynamic web pages. The document discusses PHP basics like variables, arrays, functions, and interacting with URLs, APIs, databases and more. It provides examples to demonstrate how to display data, parse XML/JSON, load content from web APIs, and talk to MySQL databases using PHP. Node.js is introduced as a JavaScript runtime that allows writing server-side code with JavaScript in an event-driven, non-blocking way.
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 7 is a major release that provides significant performance improvements over PHP 5, making PHP 7 as fast as or faster than HHVM. It removes deprecated features and provides new features like scalar type hints, return type hints, the spaceship and coalesce operators, anonymous classes, and group use declarations. Developers are encouraged to test their applications on PHP 7 to take advantage of these improvements and prepare for the future of PHP.
The document provides an introduction and overview of PHP, including:
- PHP is a server-side scripting language used for web development and can be embedded into HTML. It is commonly used to manage dynamic content, databases, sessions, and build ecommerce sites.
- Common uses of PHP include handling forms, accessing and modifying database elements, setting and accessing cookies, and restricting user access to website pages.
- The document then covers PHP syntax, variables, operators, conditional statements, loops, and arrays to provide the basic building blocks of the language.
Keep hearing about Plack and PSGI, and not really sure what they're for, and why they're popular? Maybe you're using Plack at work, and you're still copying-and-pasting `builder` lines in to your code without really knowing what's going on? What's the relationship between Plack, PSGI, and CGI? Plack from first principles works up from how CGI works, the evolution that PSGI represents, and how Plack provides a user-friendly layer on top of that.
This document provides an overview of server-side scripting using PHP. It includes 15 questions covering PHP topics like variables, data types, arrays, functions, and form handling. The questions are worth a total of 15 marks and include multiple choice, fill in the blank, true/false, and code writing questions. The document then provides details on PHP including an introduction, how it is well-suited for web development, examples of first PHP code, and explanations of variables, data types, arrays, control structures, functions and comments.
Functions allow programmers to organize and reuse code. PHP has many built-in functions for common string and date/time operations. Programmers can also define their own functions. Functions can accept arguments, use default values, be called by value or reference, and be recursive. Variable scope inside functions prevents naming collisions with external variables. Well-formed PHP functions follow naming conventions and can contain other functions and classes.
why function,built in function,arguments,default arguments,call by value,call by reference,recursive function,variable scope,user defined function,date/time function
PHP is a scripting language used for web development that allows developers to write dynamically generated web pages quickly. Key points about PHP include:
- PHP code must be contained within <?php ?> tags or <? ?> shorthand tags
- Files containing PHP code must have a .php extension
- Variables, operators, functions, and other PHP elements allow dynamic content and programming logic
- Functions can take parameters and return values
- Files and sessions allow sharing data across pages
Training on php by cyber security infotech (csi). Cs-infotech is one of the best cyber security and website development company in India. we also provide Network security, software development, Cyber security corporate training and SEO and SMO services.
Our services are Employee Monitoring System,Employee Monitoring Software,Website Audit,Network Security,Network Audit and Information Security.
বাংলাদেশের অর্থনৈতিক সমীক্ষা ২০২৪ [Bangladesh Economic Review 2024 Bangla.pdf] কম্পিউটার , ট্যাব ও স্মার্ট ফোন ভার্সন সহ সম্পূর্ণ বাংলা ই-বুক বা pdf বই " সুচিপত্র ...বুকমার্ক মেনু 🔖 ও হাইপার লিংক মেনু 📝👆 যুক্ত ..
আমাদের সবার জন্য খুব খুব গুরুত্বপূর্ণ একটি বই ..বিসিএস, ব্যাংক, ইউনিভার্সিটি ভর্তি ও যে কোন প্রতিযোগিতা মূলক পরীক্ষার জন্য এর খুব ইম্পরট্যান্ট একটি বিষয় ...তাছাড়া বাংলাদেশের সাম্প্রতিক যে কোন ডাটা বা তথ্য এই বইতে পাবেন ...
তাই একজন নাগরিক হিসাবে এই তথ্য গুলো আপনার জানা প্রয়োজন ...।
বিসিএস ও ব্যাংক এর লিখিত পরীক্ষা ...+এছাড়া মাধ্যমিক ও উচ্চমাধ্যমিকের স্টুডেন্টদের জন্য অনেক কাজে আসবে ...
PHP is a server-side scripting language commonly used for web development. It allows developers to add dynamic content to websites. Key points:
- PHP scripts are executed on the server and output HTML, JavaScript, or other code to browsers.
- PHP supports variables, arrays, functions, classes, and control structures like if/else statements.
- External data like from text files or databases can be easily incorporated into dynamic web pages using PHP.
- PHP files have a .php extension and PHP code is delimited by <?php ?> tags within HTML files or standalone PHP files.
PHP Basics is a presentation that introduces PHP. It discusses that PHP is a server-side scripting language used for building dynamic websites. It can be embedded into HTML. When a PHP file is requested, the server processes the PHP code and returns the output to the browser as HTML. The presentation covers PHP syntax, variables, data types, operators, functions, and conditional statements. It provides examples to illustrate basic PHP concepts and functionality.
PHP is a widely-used open source scripting language suited for web development. It allows embedding code into HTML pages to make them dynamic. PHP code is executed on the server and generates HTML that is sent to the client. Key features include using variables, conditional statements, loops, functions, and interacting with databases or external sources. The document provides an introduction to basic PHP syntax and constructs like variables, arrays, operators, control structures, and functions.
Practical tips for dealing with projects involving legacy code. Covers investigating past projects, static analysis of existing code, and methods for changing legacy code.
Presented at PHP Benelux '10
PHP is a server-side scripting language commonly used for web development. It allows developers to add dynamic content to websites. PHP code is embedded within HTML and executed on the server before the page is sent to the browser. The document provides an introduction and overview of PHP, covering its history, syntax based on Perl and C, how PHP scripts are parsed and executed, variables, arrays, operators, control structures like if/else and loops, functions to include external files, and how PHP can be used to retrieve and display external data.
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.
The document provides an overview and introduction to PHP including:
- PHP is a server-side scripting language used for web development. It was created by Rasmus Lerdorf in 1995.
- It discusses PHP basics like syntax, variables, strings, arrays, functions, and how to interact with forms and retrieve data from web pages.
- It also covers using PHP to communicate with backend databases and services to fetch and parse XML/JSON data.
This document provides an introduction to PHP, covering its history, parsing, variables, arrays, operators, functions, control structures, and use of external data files. PHP is an open-source server-side scripting language that was originally created in 1994 and is widely used for web development. It allows developers to embed code into HTML pages that is executed on the server to dynamically generate content.
This document provides an overview of PHP, its uses, installation, configuration, and basic concepts. It discusses that PHP is a widely used programming language for building dynamic websites. It can be installed along with Apache and MySQL on a server. The document also covers PHP variables, data types, flow control, functions, and how to work with strings and numbers.
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 is a server-side scripting language commonly used with the LAMP stack. It allows developers to easily create dynamic web pages. The document discusses PHP basics like variables, arrays, functions, and interacting with URLs, APIs, databases and more. It provides examples to demonstrate how to display data, parse XML/JSON, load content from web APIs, and talk to MySQL databases using PHP. Node.js is introduced as a JavaScript runtime that allows writing server-side code with JavaScript in an event-driven, non-blocking way.
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 7 is a major release that provides significant performance improvements over PHP 5, making PHP 7 as fast as or faster than HHVM. It removes deprecated features and provides new features like scalar type hints, return type hints, the spaceship and coalesce operators, anonymous classes, and group use declarations. Developers are encouraged to test their applications on PHP 7 to take advantage of these improvements and prepare for the future of PHP.
The document provides an introduction and overview of PHP, including:
- PHP is a server-side scripting language used for web development and can be embedded into HTML. It is commonly used to manage dynamic content, databases, sessions, and build ecommerce sites.
- Common uses of PHP include handling forms, accessing and modifying database elements, setting and accessing cookies, and restricting user access to website pages.
- The document then covers PHP syntax, variables, operators, conditional statements, loops, and arrays to provide the basic building blocks of the language.
Keep hearing about Plack and PSGI, and not really sure what they're for, and why they're popular? Maybe you're using Plack at work, and you're still copying-and-pasting `builder` lines in to your code without really knowing what's going on? What's the relationship between Plack, PSGI, and CGI? Plack from first principles works up from how CGI works, the evolution that PSGI represents, and how Plack provides a user-friendly layer on top of that.
This document provides an overview of server-side scripting using PHP. It includes 15 questions covering PHP topics like variables, data types, arrays, functions, and form handling. The questions are worth a total of 15 marks and include multiple choice, fill in the blank, true/false, and code writing questions. The document then provides details on PHP including an introduction, how it is well-suited for web development, examples of first PHP code, and explanations of variables, data types, arrays, control structures, functions and comments.
Functions allow programmers to organize and reuse code. PHP has many built-in functions for common string and date/time operations. Programmers can also define their own functions. Functions can accept arguments, use default values, be called by value or reference, and be recursive. Variable scope inside functions prevents naming collisions with external variables. Well-formed PHP functions follow naming conventions and can contain other functions and classes.
why function,built in function,arguments,default arguments,call by value,call by reference,recursive function,variable scope,user defined function,date/time function
PHP is a scripting language used for web development that allows developers to write dynamically generated web pages quickly. Key points about PHP include:
- PHP code must be contained within <?php ?> tags or <? ?> shorthand tags
- Files containing PHP code must have a .php extension
- Variables, operators, functions, and other PHP elements allow dynamic content and programming logic
- Functions can take parameters and return values
- Files and sessions allow sharing data across pages
Training on php by cyber security infotech (csi). Cs-infotech is one of the best cyber security and website development company in India. we also provide Network security, software development, Cyber security corporate training and SEO and SMO services.
Our services are Employee Monitoring System,Employee Monitoring Software,Website Audit,Network Security,Network Audit and Information Security.
বাংলাদেশের অর্থনৈতিক সমীক্ষা ২০২৪ [Bangladesh Economic Review 2024 Bangla.pdf] কম্পিউটার , ট্যাব ও স্মার্ট ফোন ভার্সন সহ সম্পূর্ণ বাংলা ই-বুক বা pdf বই " সুচিপত্র ...বুকমার্ক মেনু 🔖 ও হাইপার লিংক মেনু 📝👆 যুক্ত ..
আমাদের সবার জন্য খুব খুব গুরুত্বপূর্ণ একটি বই ..বিসিএস, ব্যাংক, ইউনিভার্সিটি ভর্তি ও যে কোন প্রতিযোগিতা মূলক পরীক্ষার জন্য এর খুব ইম্পরট্যান্ট একটি বিষয় ...তাছাড়া বাংলাদেশের সাম্প্রতিক যে কোন ডাটা বা তথ্য এই বইতে পাবেন ...
তাই একজন নাগরিক হিসাবে এই তথ্য গুলো আপনার জানা প্রয়োজন ...।
বিসিএস ও ব্যাংক এর লিখিত পরীক্ষা ...+এছাড়া মাধ্যমিক ও উচ্চমাধ্যমিকের স্টুডেন্টদের জন্য অনেক কাজে আসবে ...
How to Setup Warehouse & Location in Odoo 17 InventoryCeline George
In this slide, we'll explore how to set up warehouses and locations in Odoo 17 Inventory. This will help us manage our stock effectively, track inventory levels, and streamline warehouse operations.
This presentation was provided by Steph Pollock of The American Psychological Association’s Journals Program, and Damita Snow, of The American Society of Civil Engineers (ASCE), for the initial session of NISO's 2024 Training Series "DEIA in the Scholarly Landscape." Session One: 'Setting Expectations: a DEIA Primer,' was held June 6, 2024.
Walmart Business+ and Spark Good for Nonprofits.pdfTechSoup
"Learn about all the ways Walmart supports nonprofit organizations.
You will hear from Liz Willett, the Head of Nonprofits, and hear about what Walmart is doing to help nonprofits, including Walmart Business and Spark Good. Walmart Business+ is a new offer for nonprofits that offers discounts and also streamlines nonprofits order and expense tracking, saving time and money.
The webinar may also give some examples on how nonprofits can best leverage Walmart Business+.
The event will cover the following::
Walmart Business + (https://business.walmart.com/plus) is a new shopping experience for nonprofits, schools, and local business customers that connects an exclusive online shopping experience to stores. Benefits include free delivery and shipping, a 'Spend Analytics” feature, special discounts, deals and tax-exempt shopping.
Special TechSoup offer for a free 180 days membership, and up to $150 in discounts on eligible orders.
Spark Good (walmart.com/sparkgood) is a charitable platform that enables nonprofits to receive donations directly from customers and associates.
Answers about how you can do more with Walmart!"
हिंदी वर्णमाला पीपीटी, hindi alphabet PPT presentation, hindi varnamala PPT, Hindi Varnamala pdf, हिंदी स्वर, हिंदी व्यंजन, sikhiye hindi varnmala, dr. mulla adam ali, hindi language and literature, hindi alphabet with drawing, hindi alphabet pdf, hindi varnamala for childrens, hindi language, hindi varnamala practice for kids, https://www.drmullaadamali.com
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Dr. Vinod Kumar Kanvaria
Exploiting Artificial Intelligence for Empowering Researchers and Faculty,
International FDP on Fundamentals of Research in Social Sciences
at Integral University, Lucknow, 06.06.2024
By Dr. Vinod Kumar Kanvaria
A review of the growth of the Israel Genealogy Research Association Database Collection for the last 12 months. Our collection is now passed the 3 million mark and still growing. See which archives have contributed the most. See the different types of records we have, and which years have had records added. You can also see what we have for the future.
This document provides an overview of wound healing, its functions, stages, mechanisms, factors affecting it, and complications.
A wound is a break in the integrity of the skin or tissues, which may be associated with disruption of the structure and function.
Healing is the body’s response to injury in an attempt to restore normal structure and functions.
Healing can occur in two ways: Regeneration and Repair
There are 4 phases of wound healing: hemostasis, inflammation, proliferation, and remodeling. This document also describes the mechanism of wound healing. Factors that affect healing include infection, uncontrolled diabetes, poor nutrition, age, anemia, the presence of foreign bodies, etc.
Complications of wound healing like infection, hyperpigmentation of scar, contractures, and keloid formation.
Digital Artefact 1 - Tiny Home Environmental Design
PHP-03-Functions.ppt
1. PHP Functions / Modularity
Dr. Charles Severance
www.wa4e.com
2. Why Functions?
• PHP has lots of built-in functions that we use all the
time.
• We write our own functions when our code reaches a
certain level of complexity.
3. To function or not to function...
• Organize your code into “paragraphs” - capture a complete
thought and “name it”.
• Don’t repeat yourself - make it work once and then reuse it.
• If something gets too long or complex, break up logical
chunks and put those chunks in functions.
• Make a library of common stuff that you do over and over -
perhaps share this with your friends...
6. Built-In Functions...
• Much of the power of PHP comes from its built-in functions.
• Many are modeled after C string library functions (i.e.
strlen()).
echo strrev(" .dlrow olleH"); echo
str_repeat("Hip ", 2); echo
strtoupper("hooray!");
echo strlen("intro");
echo "n";
Hello world.
Hip Hip
HOORAY!
5
7. Defining Your Own Functions
We use the function keyword to define a function, we name the
function and take optional argument variables. The body of the
function is in a block of code { }
function greet() {
print "Hellon";
}
greet();
greet();
Hello
Hello
8. Choosing Function Names
• Much like variable names - but do not start with a dollar sign
• Start with a letter or underscore - consist of letters, numbers,
and underscores ( _ )
• Avoid built-in function names
• Case does not matter – but please do not take advantage of
this
9. Return Values
Often a function will take its arguments, do some computation,
and return a value to be used as the value of the function call in
the calling expression. The return keyword is used for this.
function greeting() {
return "Hello";
}
print greeting() . " Glennn";
print greeting() . " Sallyn";
Hello Glenn
Hello Sally
10. Arguments
Functions can choose to accept optional arguments. Within the
function definition the variable names are effectively “aliases” to the
values passed in when the function is called.
function howdy($lang) {
if ( $lang == 'es' ) return "Hola";
if ( $lang == 'fr' ) return "Bonjour";
return "Hello";
}
print howdy('es') . " Glennn";
print howdy('fr') . " Sallyn";
Hola Glenn
Bonjour Sally
11. Optional Arguments
Arguments can have defaults, and so can be omitted.
function howdy($lang='es') {
if ( $lang == 'es' ) return "Hola";
if ( $lang == 'fr' ) return "Bonjour";
return "Hello";
}
print howdy() . " Glennn";
print howdy('fr') . " Sallyn";
Hola Glenn
Bonjour Sally
12. Call By Value
• The argument variable within the function is an “alias” to the
actual variable.
• But even further, the alias is to a *copy* of the actual variable
in the function call.
function double($alias) {
$alias = $alias * 2;
return $alias;
}
$val = 10;
$dval = double($val);
echo "Value = $val Doubled = $dvaln";
Value = 10 Doubled = 20
13. Call By Reference
Sometimes we want a function to change one of its arguments,
so we indicate that an argument is “by reference” using ( & ).
function triple(&$realthing) {
$realthing = $realthing * 3;
}
$val = 10;
triple($val);
echo "Triple = $valn";
Triple = 30
16. Variable Scope
• In general, variable names used inside of function code do
not mix with the variables outside of the function to avoid
unexpected side effects if two programmers use the same
variable name in different parts of the code.
• We call this “name spacing” the variables. The function
variables are in one “name space” whilst the main variables
are in another “name space”.
http://php.net/manual/en/language.variables.scope.php
17. Normal Scope (isolated)
function tryzap() {
$val = 100;
}
$val = 10;
tryzap();
echo "TryZap = $valn";
TryZap = 10
http://php.net/manual/en/language.variables.superglobals.php
Except for $_GET
18. Global Scope (shared)
function dozap() {
global $val;
$val = 100;
}
$val = 10;
dozap();
echo "DoZap = $valn";
DoZap = 100
Use this wisely, young
Jedi...
19. Global Variables – Use Rarely
• Passing variable in as parameter
• Passing value back as return value
• Passing variable in by reference
• If you use global variables, use long names with nice
unique prefixes
global $LastOAuthBodyBaseString;
global $LAST_OAUTH_BODY_BASE_STRING;
20. Coping with Missing Bits
Sometimes, depending on the version or configuration of a
particular PHP instance, some functions may be missing. We can
check that...
if (function_exists("array_combine")){
echo "Function exists";
} else {
echo "Function does not exist";
}
This allows for evolution.
22. One Heck of a Function…
• PHP is a very configurable system and has lots of capabilities
that can be plugged in.
• The phpinfo() function prints out the internal configuration
capabilities of your particular PHP installation,
<?php
phpinfo();
?>
27. Including Files in PHP
• include "header.php"; - Pull the file in here
• include_once "header.php"; - Pull the file in here unless it
has already been pulled in before
• require "header.php"; - Pull in the file here and die if it is
missing
• require_once "header.php"; - You can guess what this
means...
• These can look like functions - require_once("header.php");
31. Summary
• Built-in functions
• Making new functions
• Arguments - pass by value and pass by reference
• Including and requiring files
• Checking to see if functions are present
32. 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. Please retain and maintain this page as you remix and republish these materials. Please add any of your own improvements or contributions.