PHP Functions - PowerPoint PPT Presentation

1 / 5
About This Presentation
Title:

PHP Functions

Description:

PHP Functions – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 6
Provided by: paws3
Category:
Tags: php | functions | var

less

Transcript and Presenter's Notes

Title: PHP Functions


1
PHP Functions
2
Function Advantages
  • Blocks of code.
  • Provide a way to reuse code.
  • A function should only perform one task. This
    helps make the code more modular.
  • Try example 2-3 using the bold function.
  • Note that you pass an argument to the function.
  • In this case the argument is a string value.

3
Function - Parts and Pieces
  • function bold(string)
  • print ltbgt . string. ltbgt

Declares the function
Name of the function
Parameter accepted by the function. Parameter and
return types are not declared when a function is
defined.
4
Variable Scope
  • The variables used in a function are limited to
    that function
  • function doublevalue(var)
  • temp var 2
  • variable 5
  • doublevalue(variable)
  • print \temp is temp
  • // the output is temp is

5
Global Variables
  • Variables that are the same everywhere in your
    code.
  • Be careful when using global variables.
  • Unlike most other programming languages, global
    variables are declared inside the function
    itself.
  • function doublevalue()
  • global temp
  • temp temp 2
Write a Comment
User Comments (0)
About PowerShow.com