8
3/26/2019 ..\demo>c:\xampp\php\php word.php a b c d e f Direct invocation. Input: command line arguments. Output: text -> standard output. URL: http://dcm.uhcl.edu/yue/courses/csci5333/current/notes/php/SQL_PHP.htm l DCM web server: map URL to a filename. Map to: /index.html URL: http://localhost/php/csci5333/spring2019/hello.html map to: C:\xampp\htdocs\php\csci5333\Spring2019\hello.html Example: [1] HTTP request: http://localhost/php/csci5333/spring2019/hello2.php Apache: map URL to: C:\xampp\htdocs\php\csci5333\Spring2019\hello2.php [2] Apache invoke PHP interpreter: steps 2 to 4: CGI C:\xampp\php\php.exe

dcm.uhcl.edudcm.uhcl.edu/.../csci5333/spring2019/demo/2019_3_26.docx · Web view3/26/2019.. \demo>c:\xampp\php\php word.php a b c d e f Direct invocation. Input: command line arguments

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: dcm.uhcl.edudcm.uhcl.edu/.../csci5333/spring2019/demo/2019_3_26.docx · Web view3/26/2019.. \demo>c:\xampp\php\php word.php a b c d e f Direct invocation. Input: command line arguments

3/26/2019

..\demo>c:\xampp\php\php word.php a b c d e f

Direct invocation. Input: command line arguments. Output: text -> standard output.

URL: http://dcm.uhcl.edu/yue/courses/csci5333/current/notes/php/SQL_PHP.html

DCM web server: map URL to a filename.

Map to:

/index.html

URL:

http://localhost/php/csci5333/spring2019/hello.html

map to:

C:\xampp\htdocs\php\csci5333\Spring2019\hello.html

Example:

[1] HTTP request: http://localhost/php/csci5333/spring2019/hello2.php

Apache: map URL to:

C:\xampp\htdocs\php\csci5333\Spring2019\hello2.php

[2] Apache invoke PHP interpreter: steps 2 to 4: CGI

C:\xampp\php\php.exe

Windows: Apache configured to associate .php o C:\xampp\php\php.exe

*nix: shebang as the first tells the location of the interpreter.

[3] Runs hello2.php

Page 2: dcm.uhcl.edudcm.uhcl.edu/.../csci5333/spring2019/demo/2019_3_26.docx · Web view3/26/2019.. \demo>c:\xampp\php\php word.php a b c d e f Direct invocation. Input: command line arguments

[4] Output of helle2.php -> Apache

<html><head> <title>Hello world.</title></head><body> <p>Hello World from CSCI 5333,</p></body></html>

[5] Apache uses [4] -> HTTP Response.

HTTP/1.1 200 OKDate: Tue, 26 Mar 2019 21:46:58 GMTServer: Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.6.19X-Powered-By: PHP/5.6.19Content-Length: 118Keep-Alive: timeout=5, max=100Connection: Keep-AliveContent-Type: text/html; charset=UTF-8

<html><head> <title>Hello world.</title></head><body> <p>Hello World from CSCI 5333,</p> </body></html>

Page 3: dcm.uhcl.edudcm.uhcl.edu/.../csci5333/spring2019/demo/2019_3_26.docx · Web view3/26/2019.. \demo>c:\xampp\php\php word.php a b c d e f Direct invocation. Input: command line arguments

For:

<?php// We'll be outputting a txt content

header('Content-Type: text/txt');?>

<html><head>… Will create:

HTTP Response header changed:

Page 4: dcm.uhcl.edudcm.uhcl.edu/.../csci5333/spring2019/demo/2019_3_26.docx · Web view3/26/2019.. \demo>c:\xampp\php\php word.php a b c d e f Direct invocation. Input: command line arguments

Note the HTML code will not be interpreted by the browser and is displayed as is.

CGI:

GET Method:

URL: http://localhost/php/csci5333/spring2019/hello.php?name=yue

Query string: name=yue (name value pairs)

Request Header:

…Request URL: http://localhost/php/csci5333/spring2019/hello.php? name=yue …

Page 5: dcm.uhcl.edudcm.uhcl.edu/.../csci5333/spring2019/demo/2019_3_26.docx · Web view3/26/2019.. \demo>c:\xampp\php\php word.php a b c d e f Direct invocation. Input: command line arguments

Input data: part of URL, part of HTTP Request Header

Webword.php:

http://localhost/php/csci5333/spring2019/webword.php?chars=abcdef

Request header:

Request URL: http://localhost/php/csci5333/spring2019/webword.php?chars=abcdef

Page 6: dcm.uhcl.edudcm.uhcl.edu/.../csci5333/spring2019/demo/2019_3_26.docx · Web view3/26/2019.. \demo>c:\xampp\php\php word.php a b c d e f Direct invocation. Input: command line arguments

$chars = preg_split("//",$inputChars);

Split $inputChar (e.g. abcdef) into $chars: ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’.

Page 7: dcm.uhcl.edudcm.uhcl.edu/.../csci5333/spring2019/demo/2019_3_26.docx · Web view3/26/2019.. \demo>c:\xampp\php\php word.php a b c d e f Direct invocation. Input: command line arguments
Page 8: dcm.uhcl.edudcm.uhcl.edu/.../csci5333/spring2019/demo/2019_3_26.docx · Web view3/26/2019.. \demo>c:\xampp\php\php word.php a b c d e f Direct invocation. Input: command line arguments

Output:

<html> <body> There are 3 words containing all supplied characters:</ol><li>barefaced</li><li>boldface</li><li>feedback</li></ol></body> </html>

HTTP Response

HTTP/1.1 200 OKDate: Tue, 26 Mar 2019 22:53:36 GMTServer: Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.6.19X-Powered-By: PHP/5.6.19Content-Length: 162Keep-Alive: timeout=5, max=100Connection: Keep-AliveContent-Type: text/html; charset=UTF-8

<html><body>There are 3 words containing all supplied characters:</ol> <li>barefaced</li> <li>boldface</li> <li>feedback</li></ol></body></html>