1 / 7

More PHP…

More PHP…. Understanding Variable Scope. The term scope refers to the places within a script where a particular variable is visible. The six basic scope rules in PHP are as follows : Built-in superglobal variables are visible everywhere within a script.

medea
Télécharger la présentation

More PHP…

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. More PHP…

  2. Understanding Variable Scope • The term scope refers to the places within a script where a particular variable is visible. The six basic scope rules in PHP are as follows: • Built-in superglobal variables are visible everywhere within a script. • Constants, once declared, are always visible globally; that is, they can be used inside and outside functions. • Global variables declared in a script are visible throughout that script, but not inside functions. • Variables inside functions that are declared as global refer to the global variables of the same name. • Variables created inside functions and declared as static are invisible from outside the function but keep their value between one execution of the function and the next. • Variables created inside functions are local to the function and cease to exist when the function terminates.

  3. PHP Simple eCommerce • Bob’s Auto Parts… • Retrieve HTTP_POST • Quick sanity check - if ($totalqty == 0) • Date() Function • Conditional Statement • Define() constant variables • Operator Precedence (calc tax rate) • Why would this NOT work in an actual business?

  4. PHP while Loops • Freight calculator… • Static vs dynamic table generation. • Which way is better? Why?

  5. PHP Better eCommerce… • Same as Simple, BUT… • With a flat file we can record orders and view them later. • Some rants about flat files • Security! Is the setup that I have currently secure? • PHP File system Functions (http://us.php.net/manual/en/ref.filesystem.php) • fopen(), flock(), fwrite(), fclose(), fgets(), fgetss(), fgetcsv(), feof()

  6. PHP Better eCommerce • What are some of the issues with using a flat file? • Is there a time where flat files would be good to use? • Is there anything better?

  7. Mid Term Review • HTML • CSS • JavaScript • PHP

More Related