Download presentation
Presentation is loading. Please wait.
Published byNorah Goodman Modified over 8 years ago
1
1 An Introduction to Dreamweaver and PHP Part B: Some introductory PHP and JavaScript
2
2 Entering Text In the remaining rows we will display the date using HTML, PHP and JavaScript. In the first column, enter the terms “HTML”, “PHP” and “JavaScript” respectively. –In Design view, place the cursor in the appropriate cell and type. –Or in Code view, identify the appropriate pair and type code between the tags.
3
3 Place the cursor in the second column, second row and go to Insert/Date on the menubar and use the dialog box to select the desired format.
4
4 HTML Date Code Version: just text. The file would have to be updated each day to display the correct date.
5
5 With the cursor in the second column of the third row, go to Insert/PHP Object/Code Block on the menubar.
6
6 Start typing PHP code print date(‘D, F j, Y g:i A’); Note the word print turned blue – it’s a keyword.
7
7 Webopedia keyword definition
8
8 Continue typing PHP code print date(‘D, F j, Y g:i A’); Note that not only does date turn blue to indicate that it is a keyword, but also after typing the opening parenthesis, a tip is displayed to inform you that a string corresponding to the date format is needed. The item in the square brackets is optional.
9
9 Finish typing print date(‘D, F j, Y g:i A’); Note that the format string is in single quotes and that Dreamweaver puts it in another color.
10
10 The semicolon delimiter A delimiter is some character or set of characters (code) that is used to determine where one thing ends and the next thing begins. PHP uses a semicolon to delimit statements. A statement is a small unit of code (an instruction) which has an established effect. We inserted a PHP code block – a block is a set of statements. –Here our block will only have one statement.
11
11 The functions print and date A function is a set of code with a name and a defined action. A function may need some information to perform its action – this information is sent by using arguments (data passed to the function). The arguments are usually placed in parentheses when the function is being called upon to perform its action. –The format string seen in the date is an argument. –The print function also has an argument (the thing to be printed) but it uses a different style with its argument simply following it on the line with no parentheses.
12
12 Go to Insert/PHP Object/Comment on the menubar
13
13 Anything typed between the /* and the */ will correspond to a PHP comment. This type of comment is known as a C-style multi-line comment because this was the way to designate a comment in the C programming language. Another style is to use two slashes // and anything following the two slashes on the same line is a comment.
14
14 Dreamweaver uses yet another color for comments.
15
15 The PHP icon Note that in Design, Dreamweaver inserts a PHP icon to indicate that there is PHP code in this portion of the page. This icon will not be seen by the viewer of the page.
16
16 Place the cursor in the 4 th row, 2 nd column, go to Insert/Tag. Choose HTML Tags and script in the dialog box. Click Insert.
17
17 Use the drop-down list to choose JavaScript as the language and text/javascript as the type. Click OK and then Close the previous dialog box.
18
18 Result: in which one places the JavaScript code
19
19 Enter the JavaScript code seen below for writing the date
20
20 References PHP for the World Wide Web, 2 nd edition, Larry Ullman, Peachpit Press, 2004. http://www.webopedia.com
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.