PHP Including files PowerPoint PPT Presentation

presentation player overlay
1 / 9
About This Presentation
Transcript and Presenter's Notes

Title: PHP Including files


1
PHP Including files
  • If pages have a common look and feel on your web
    site ? make up some template and include them in
    your php scripts
  • Example
  • Templated HTML files
  • PHP script using the templated HTML files

2
PHP Template file
  • Inside file header.inc
  • lthtmlgt
  • lttitlegtOur web sitelt/titlegt
  • ltbodygt
  • lth1gtWeb Programming Languageslt/h1gt
  • lth2gtPHPlt/h2gt

3
PHP script including the template file
  • lt? include(header.inc) ?gt
  • ltbrgtltbrgt
  • Today Introduction to PHP
  • lt/bodygtlt/htmlgt
  • The syntax is
  • include(NAME_OF_FILE)

4
PHP - Variables
  • Variable name starts with a letter or _,
    followed by letters, _s, or digits
  • PHP is a loosely typed language
  • ? no declaration of variables (like Perl)
  • Variable names are case sensitive
  • // This is a PHP comment
  • / Multi-line comment
  • Same as C and Java
  • /

5
PHP - Variables
  • a 3
  • b 1.43
  • c 1.3 e4
  • d 7E-10
  • first1 Mike // ok
  • first2 Sarah // ok
  • first3 Jane // ok

6
PHP Printing variables
  • a Mike
  • echo hello a // ? hello Mike
  • Using double quotes, variables expands
  • echo hello a // ? hello a
  • Using single quotes, variables do not expand
  • print Using print Hello a
  • print(using print( ) Hello a)
  • print Printing using severalltbrgt
  • Lines

7
PHP Here document printing
  • a Mike
  • echo hello a // ? hello Mike
  • Using double quotes, variables expands
  • echo hello a // ? hello a
  • Using single quotes, variables do not expand
  • Here document syntax
  • echo ltltltHI
  • my name is a
  • HI

8
PHP Unix commands
  • Using back quotes, we can run Unix commands from
    inside a php script
  • today date
  • echo Todays date is today
  • ? Mon Aug 18 162721 EDT 2008

9
PHP Variable scope
  • A variable is in scope until the end of the PHP
    script (there is an exception for functions)
Write a Comment
User Comments (0)
About PowerShow.com