PHP - Overview: Tutorial Installation Postgresql With PHP Extended Example
PHP - Overview: Tutorial Installation Postgresql With PHP Extended Example
Introduction
Tutorial
Installation
PostgreSQL with PHP
Extended example
Introduction
PHP (recursive acronym for "PHP:
Hypertext Preprocessor")
◼ widely-used Open Source general-purpose
scripting language
◼ especially suited for Web development
◼ can be embedded into HTML.
<html>
<head>
<title>Example</title>
</head>
<body>
<?php echo "Hi, I'm a PHP script!"; ?>
</body>
</html>
What can PHP do?
Server-side scripting
◼ most traditional and main target field
◼ need three things to make this work
PHP parser (CGI or server module)
webserver – with connected PHP installation
web browser
Command line scripting
◼ PHP script to run it without any server or browser
◼ need the PHP parser to use it this way
Writing client-side GUI applications
◼ not the best language to write windowing
applications
◼ use PHP-GTK to write such programs
Tutorial
What do I need?
Your first PHP-enabled page
Something Useful
Dealing with Forms
What's next?
What do I need?
Assume that your server has support
for PHP activated and that all files
ending in .php are handled by PHP
Create your .php files and put them in
your web directory and the server will
magically parse them for you
No need to compile anything
Develop locally
◼ install a web server, such as Apache
◼ install PHP
◼ install a database as well, such as
PostgreSQL.
First PHP-enabled page
Create a file named hello.php
Put it in your web servers directory
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo "<p>Hello World</p>"; ?>
</body>
</html>
print $_POST['username'];
print $_REQUEST['username'];
import_request_variables('p', 'p_');
print $p_username;
print $HTTP_POST_VARS['username'];
show_answers.php
Hi
<?php echo $_POST["name"]; ?>.
You are <?php echo $_POST["age"]; ?> years old.