Introduction to PHP - instesre.org

Introduction To PHP Instesre Org-ppt Download

  • Date:05 Aug 2020
  • Views:14
  • Downloads:0
  • Size:307.50 KB

Share Presentation : Introduction To PHP Instesre Org

Download and Preview : Introduction To PHP Instesre Org

Report CopyRight/DMCA Form For : Introduction To PHP Instesre Org


Transcription:

Introduction to PHP ChapterWorking with PHP JavaScript vs PHP PHP scripts are similar to JavaScript scripts but be carefulwith syntax .
PHP variables always begin with a symbol There is noequivalent to JavaScript s var data declaration PHP scripts are embedded within a php tag PHP functions are similar to JavaScript functions but.
argument passing is easier PHP functions can return a single value with multiplevalues returned as elements in an array PHP scripts can read data from and write data to a file on aremote server .
PHP outputs can be used within the PHP application but not passed back to JavaScript Solving the Water Vapor Pass instrument serial number time andplace and instrument output voltages .
Find calibration constants for the instrument Calculate sun s position based on time andplace long Calculate total column water vapor short Where should the solar position calculations.
be done they depend on time and place butare independent of the instrument outputs Decisions decisions Solar position calculations could be donein JavaScript but we will do them in PHP.
to learn how to use the language Document 8 1 gives a completeJavaScript solution assuming that theinstrument calibration constants areaknown Eventually these calculations.
need to be translated into PHP A self contained JavaScript JavaScript ction getSunpos m d y hour minute se... h Math .
xplicit type conversions to make sure inputs are treated like numbers not strings parseInt m 10 d parseInt d 10 y parseInt y 10 ur parseFloat hour minute parseFloat minute cond parseFloat second t parseFloat Lat Lon parseFloat Lon .
Note the use of parseFloat and parseInt to convertform field values to numbers function get PW IR1 IR2 A B C beta tau ... var x C airm tau Math log IR2 IR1 A B var PW Math pow x 1 beta airm .
return Math round PW 1000 1000 PHP equivalent m getSunpos POST mon POST day... POST min POST sec POST lat POST lon .
x C m tau log IR2 IR1 A B PW pow x 1 beta m An HTML interface to PHP Output from PHP Returning multiple values.
Document 8 4 circleStuff php Note that this function CIRCLESTUFF r will also work because PHP function names are case insensitive function CircleStuff r .
area M PI r r circumference 2 M PI r However this won t work return array AREA circumference because variable names are case sensitive .
return array area circumference list area circumference CircleStuff 3 echo area circumference More about file I Otext file contains wind speed data .
2 0 4 3 8 4 5 3 3 1 9 1 6 3 7 0 8 2 3 2 8 2 4 2 5 3 2 4 1 3 9 5 0 4 4 4 4 5 5 3 0 3 7 2 2 2 06 2 8 2 3 2 3 1 2 2 4 3 1 4 0 3 6 2 9 6 0 4 4 0 8 3 8 3 5 4 5 2 7 3 4 6 6 5 2 1 6 1 2 2 3 2 46 5 9 3 1 3 2 4 5 4 4 3 9 4 4 7 5 8 4 10 2 9 2 8 1 6 3 3 1 3 5 2 2 1 4 0 4 4 2 5 4 4 0 2 9 1 75 2 3 2 1 1 5 2 3 4 1 5 3 6 0 6 0 9 7 11 3 12 7 13 0 13 0 11 6 9 9 9 6 8 7 5 4 5 1 5 3 5 6 4 4 4For each day there are 24 hourly wind speed values Missing hours are.
represented by a value of 1 Read this file and count and displaythe month 1 12 and the number of missing values for each month Write the results into a file and save it Document 8 4 windspd php inFile windspd dat .
outFile windspd out in fopen inFile r or die Can t open file out fopen c Documents and Settings All Users Documents phpout outFile... while feof in .
Read one month year of days fscanf in u u u m y nDays if feof in exit echo m y nDays br nMissing 0 .
for i 1 i nDays i hrly fscanf in f f f f f f f f f f f f f f f f f f f f f f f for hr 0 hr 23 hr echo hrly hr .
if hrly hr 1 nMissing echo hrly 23 br echo Number of missing hours this month is nMissing br fprintf out u u u r n m y nMissing .
fclose in fclose out Another applicationite an HTML document that allows a user to select a solid object shaped enter its dimensions and the material from which it is made The choices.
uld be a cube a rectangular block a sphere or a cube You could choose amber of possible materials air gold water etc Then call a PHP applicationat will find the mass of the object by calculating its volume based on the specifiedape and looking up the density of the material in a data file Document 8 5a getMass htm .
html head title Calculate mass title head body form method post action getMass php Enter length input type text name L value 3 br .
Enter width input type text name W value 2 br Enter height input type text name H value 10 br Enter radius input type text name R value 3 br select name shapes size 10 option value cube cube option .
option value cylinder cylinder option... option value block rectangular block option option value sphere sphere option select name material size 10 option value air air option .
option value aluminum aluminum option... option value gold gold option option value oxygen oxygen option option value silver silver option option value water water option .
input type submit value Click to get volume input type button value click onclick alert document form1 s... alert shapes options shapes se... form body html .
PHP the first step Display the input values print r POST This code will display something like this Array L 1 W 1 H 1 R 3 shapes cube material oxygen .
Create data files density dat volume dat material density kg m 3 shape volumewater 1000 cube L L Laluminum 2700 sphere 4 3 M PI R R R.
gold 19300 cylinder M PI R R Lsilver 10500 block L W Hoxygen 1 429 Document 8 5b getMass php print r POST .
material POST material material shape POST shapes L POST L W POST W H POST H .
R POST R echo br material shape br materialFile fopen density da... shapeFile fopen volume dat r Read materials file .
found false line fgets materialFile while feof materialFile found values fscanf materialFile s f m d if strcasecmp material m 0 .
echo material m d br found true Calculate the volume Read volume file found false .
line fgets shapeFile while feof shapeFile found values fscanf shapeFile s s s v if strcasecmp shape s 0 echo shape v br .
found true This is the clever code Close both data files fclose materialFile fclose shapeFile .
Calculate mass vv v d echo Result eval return round vv 3 kg br Document 8 11 CompoundInterest php title Calculate Compound Interest title .
head HTML PHP h3 Calculate Compound Interest h3 applications form action php SERVER PHP SELF method post Initial amount no commas input type text .
name initial value 10000 br Annual interest rate input type text name rate value 4 br How many years input type text name years value 20 br .
input type submit value Generate compound interest table initial POST initial rate POST rate years POST years .
echo initial rate years br for i 1 i years i amount initial pow 1 rate 100... echo i number format amount 2 br .
Introduction to PHP – Chapter 8 Working with PHP JavaScript vs. PHP PHP scripts are similar to JavaScript scripts, but be careful with syntax! PHP variables always begin with a “$” symbol. There is no equivalent to JavaScript’s “var” data declaration. PHP scripts are embedded within a <?php … ?> tag.

Related Presentations

Chapter 1 Introduction2 instesre org

Chapter 5: Arrays in JavaScript 5.1 Basic Array Properties 5.2 Some Operations on Arrays 5.3 Simulating Multidimensional Arrays 5.4 Using Arrays to Access the Contents of Forms

8 Views0 Downloads

http unefazulia freeforums org index php

* Protocolo de Aula Es de obligatorio cumplimiento por todos los Docentes, el Protocolo de Aula al iniciar cada sesión de clases!!! * Extracto del Manual del Estudiante UNEFA 2011 * El uniforme diario para asistir a clase será: pantalón blue jean, chemise blanca con logotipo UNEFA, por dentro del pantalón, correa y zapatos deportivos cerrados.

4 Views0 Downloads

PHP An Introduction

service support education extensions open source companies IBM uses and develops Apache and Linux; created Secure Mailer and created other software on AlphaWorks Apple released core layers of Mac OS X Server as an open source BSD operating system called Darwin; open sourcing the QuickTime Streaming Server and the OpenPlay network gaming toolkit ...

36 Views0 Downloads

Introduction to PHP

Data Types (1) PHP has eight different data types – 5 basic and 2 composite types and 1 resource type. The 5 basic data types are: integers: whole numbers in the range -2,147,483,648 to +2,147,483,647 on 32-bit architecture.

28 Views0 Downloads

Introduction to PHP Chakarov

PHP: Introduction By Trevor Adams Topics Covered Server side web programming Client/Server systems Comparison with static HTML PHP - what is it? What does it do? PHP Language basics Syntax Variables, Constants, Operators Decision making PHP and the client Client/Server on the WWW Standard web sites operate on a request/response basis A user ...

18 Views0 Downloads

Introduction to PHP University of Michigan

Introduction to PHP Dr. Charles Severance www.php-intro.com Note from Chuck. If you are using these materials, you can remove my name and URL from this replace it with your own, but please retain the CC-BY logo on the first page as well as retain the entire last page when you remix and republish these slides.

10 Views0 Downloads

Introduction to PHP Mahasarakham University

Web Development. FINAL 50%. Week5-6. Web Services. XML. Web Service Client. Web Service Server. Web2.0 Mashup. Week7. PHP template with Smarty

12 Views0 Downloads

Introduction to PHP WA4E

Introduction to PHP Last modified by: Sue Blumenberg Document presentation format: On-screen Show (16:9) Other titles: Helvetica MS Pゴシック Arial Gill Sans Lucida Grande ヒラギノ角ゴ ProN W3 Courier 1_Office Theme Office Theme PHP Arrays PHP Arrays Rock! Associative Arrays Integer Indices Key / Value Dumping an Array var_dump vs ...

15 Views0 Downloads

Introduction to PHP WPI

Introduction to PHP “PHP is a server-side scripting language designed specifically for the Web. Within an HTML page, you can embed PHP code that will be executed each time the page is visited. Your PHP code is interpreted at the Web server and generates HTML or other output that the visitor will see” (“PHP and MySQL Web Development ...

14 Views0 Downloads

Introduction to Server Side Development with PHP

PHP Comments. The types of comment styles in PHP are: Single-line comments. Lines that begin with a # are comment lines and will not be executed. Multiline (block) comments. These comments begin with a /* and encompass everything that is encountered until a closing */ tag is found. End-of-line comments

13 Views0 Downloads

Introduction to PHP and MySQL

Title: Introduction to PHP and MySQL Author: Lisa Dipippo Last modified by: Lisa DiPippo Created Date: 10/21/2003 8:11:01 PM Document presentation format

8 Views0 Downloads

Introduction to PHP

PHP and MySQL Web Development 2nd Edition, Welling & Thomson Web Database Applications with PHP & MySQL, O’Reilly Publishers PHP Cookbook, O’Reilly Publishers

13 Views0 Downloads