Blue Belt … Onlykiosk Coding …

Слайд 2

OnlyKiosk.com

OnlyKiosk.com

Слайд 3

OnlyKiosk.com

Cross-File Communication

OnlyKiosk.com Cross-File Communication

Слайд 4

OnlyKiosk.com

how to assemble two files together

OnlyKiosk.com how to assemble two files together

Слайд 5

OnlyKiosk.com

how to assemble two files together

echo “Hello,”
?>

echo “OnlyKiosk!
?>

OnlyKiosk.com how to assemble two files together echo “Hello,” ?> echo “OnlyKiosk! ?>

Слайд 6

OnlyKiosk.com

require( )
include( )

Cross-File Communication

OnlyKiosk.com require( ) include( ) Cross-File Communication

Слайд 7

OnlyKiosk.com

include() and require() are basically identical, the difference is how they handle

OnlyKiosk.com include() and require() are basically identical, the difference is how they
failures:
require() will produce a fatal error (E_COMPILE_ERROR) and stop the script
include() will only produce a warning (E_WARNING) and the script will continue
(http://www.w3schools.com/php/php_includes.asp)

Слайд 8

OnlyKiosk.com

require_once( )

assembling two files together

loading files consumes system resources,
one file should

OnlyKiosk.com require_once( ) assembling two files together loading files consumes system resources,
be loaded only once.

???

Слайд 9

OnlyKiosk.com

URL + file name

require_once( )

OnlyKiosk.com URL + file name require_once( )

Слайд 10

OnlyKiosk.com

“file name”

require_once( )

‘./file name’

the two files are in the SAME file

OnlyKiosk.com “file name” require_once( ) ‘./file name’ the two files are in
folder

. /

means the current file folder

Слайд 11

OnlyKiosk.com

but most of the time, the two files are NOT in the

OnlyKiosk.com but most of the time, the two files are NOT in the same file folder…
same file folder…

Слайд 12

OnlyKiosk.com

url

absolute URL
relative URL

Absolute URL: www folder, disc: c

Relative URL: go to the

OnlyKiosk.com url absolute URL relative URL Absolute URL: www folder, disc: c
parent file folder and then go to…

You Should Always Use Relative URL

Слайд 13

OnlyKiosk.com

../

../street_2/ blue_file.php

OnlyKiosk.com ../ ../street_2/ blue_file.php

Слайд 14

OnlyKiosk.com

../

../

../../city_2/street_3/ red_file.php

OnlyKiosk.com ../ ../ ../../city_2/street_3/ red_file.php

Слайд 15

OnlyKiosk.com

www/ blue/earth/ url.php

www/ blue/ moon/ function.php

../ means go back to the

OnlyKiosk.com www/ blue/earth/ url.php www/ blue/ moon/ function.php ../ means go back
previous level
Keep using ../ to go back to the previous level until reaching the folder where both the two files come from-- blue;
Then add the rest of the URL of the file to be linked;

Level 1

Level 2

Level 3