Send the link below via email or IMCopy
Present to your audienceStart remote presentation
- Invited audience members will follow you as you navigate and present
- People invited to a presentation do not need a Prezi account
- This link expires 10 minutes after you close the presentation
- A maximum of 30 users can follow your presentation
- Learn more about this feature in our knowledge base article
Introduction to PHP
Transcript of Introduction to PHP
<?php and ?>
You'll use these just like HTML delimiters. In between you'll add all kinds of php commands. Let's try it out. Put this code between the body tag.
<?php echo "Hello World"; ?>
Save your document. To start writing PHP you have to do a little bit of setup. Create a new HTML file. In order to add and run PHP commands, you'll have to change the file extension to .php.
In NetBeans you can simply create a new .PHP file. Create a .PHP Saving .PHP To save your page properly, save the document as test.php in your htdocs folder. This should be in C:\xampp\htdocs\
(see Intro to Web Servers if you don't have this folder) Accessing test.php Unlike regular .HTML files, you can't just double click on a .php file and run it. You can only access it through the http:// protocol to access this file, open a web browser and go to:
http://127.0.0.1/test.php Writing PHP Viewing test.php After you save, go to your browser and go to http://localhost/test.php. You should see this: Viewing the Code In the browser, view the source code. Your PHP code will not be there.
Remember the PHP code is run (or parsed) and only the output of the PHP is sent to the browser. Where's my code? It's OK, your .php document is fine and the PHP isn't gone. Go back to your text editor and it's safe.
Remember that it's parsed and you only see the output. Adding More PHP We can keep adding blocks of PHP code. Each block can contain multiple lines: <body>
echo " World";
When a web browser sends a request to your web server for a webpage, the server will scan through your PHP page, process the code and create a new temporary HTML page that is sent to the user. The temp page has no PHP in it at all. First, this is a safety feature; your PHP code can have usernames and passwords and security functions (like for logging in) that you don't want the world to see. Well, why not? Second, sending PHP to the user would be useless to them anyway. Browsers don't know how to read PHP. So it would be a waste to send it to them. So my server needs to understand PHP? Yes. That's why PHP is a SERVER-side scripting language. The server will run the code.
Server-side languages are more useful for retrieving and manipulating data. PHP is great at getting information from databases. With PHP, your web pages can now:
Register a user
Login a user
Customize the information on a page for a user
Run a search
Pull information from a database
Add, edit or delete the information in a database
Record the hits on a webpage
Create a commenting system
Upload images to a server More Info http://www.php.net
This is the site for the body that is in charge of PHP. It has a searchable database of every PHP command, what they do and examples. Bookmark this site and use it!