PHP

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

How to check features on the Server?

First, you need to locate your server root. If you installed XAMPP in the default location on Windows, the server root is located at C:\xampp\htdocs.

Server Root and Site

By default, the server root supports only one website. And if you want to support more than one, you need to create a virtual host for each site. Most PHP sites are hosted on Linux servers, which don't permit spaces in names and Linux is also case-sensitive so it's best to use lower case for all file and folder names.

Common Features of PHP

Common Features of PHP • Variables act as place holders for unknown or changing values. • Arrays hold multiple values. • Conditional statements are use to make decisions and loops to perform repetitive tasks. • Functions and objects perform preset tasks.

Suggestion for Scrip Editor

Here are some suggestions for script editors that have all those features. • PHP development tools, PDT (free, www.eclipse.org/pdt) • Komodo Edit (free, www.activestate.com/komodo-edit) • Zend Studio (not free, but they're dedicated to working with PHP and are worth investigating if you plan to do a lot of PHP work, www.zend.com/en/products/studio) • PhpED (not free, but they're dedicated to working with PHP and are worth investigating if you plan to do a lot of PHP work, www.nusphere.com/products/phped.htm) • Dreamweaver (isn't a dedicated PHP editor, but Dreamweaver CS5 and later has excellent support for PHP)

what does the phrase "PHP and HTML does not mix together" mean?

Here's the same web form in a browser. And as you can see, that paragraph isn't displayed. But if I submit the form without filling in any of th e fields, the paragraph is displayed along with other error messages. What's happened is that the PHP script has processed the form, discovered errors, and displayed all the messages. But take a look at the page's source code. There's no PHP in sight. It's just HTML. That's because PHP is a server-side technology. The PHP code remains on the server and after it's been processed or parsed, it outputs text and HTML.

Where is the Server Root on Window?

In MAMP on Mac OS X, it's at /Applications/MAMP/htdocs. htdocs is the most common name for the server root folder

Naming Variable Special Cases

Naming Variable Special Cases "$this" is a is reserved fin PHP obbject-oriented scripts avoid using any reserved words on this site (www.php.net/manual/en/reserved.php)

Naming Variable in PHP

Naming Variable in PHP it is best to choose a meaningful names for the variabl name use camel case or underscore for multiple words (ie $firstName, ie $first_name) always begin with a dollar sign ($) first character after "$" sign cannot be a number no space or punctuation marks, except the underscore (_) variable names are case-sensitive

Where is the Server Root on a remote server?

On remote servers, the server root is usually called htdocs, but public HTML is also very common.

PHP Essential

PHP Essential • All pages must be stored in the sever root ○ PHP needs to be processed by the web server before the page can be viewed in a browser. So, as a rule, you need to store all pages inside the server root. In most cases, this is a folder called htdocs. Although, it sometimes called www, www root, or public html. There are cases were PHP files can be stored outside the server root for security reasons. But that's something you can learn about at the later stage. • Use the filename extension ".php" ○ The server relies on the file name extension to know whether to process a page as PHP. Unless you're hosting a company or server administrator tells you otherwise, always use .php. You can mix pages with the .html file name extension in the same site. But it's a good idea to use .php for all files, even if they don't contain PHP code. By doing so, you can add PHP code later without needing to change the URL. • Enclose PHP code in PHP tags ○ opening tag : "<?php" ○ closing tag : "?>" ○ PHP code should be enclosed in PHP tags. The opening tag consist of an opening angle bracket, question mark,and PHP. There's no space between any of the characters. In some scripts, you'll find just the opening angle bracket followed by the question mark, without the PHP. This is a shortened version. It works on a lot of servers, but isn't guaranteed to work everywhere. So, I recommend that you should always use the full opening PHP tag. The closing tag is a question mark followed by a closing angle bracket. Now, in some cases you can omit the closing tag. But if there's any HTML or anything else on the web page other than PHP code, the closing tag must always be there. If in doubt, I recommend always using a closing tag.

Why use PHP Info?

PHP has many features but they might not be enabled on your server so it's important to know how to use a function called PHP Info to check your server's configuration. You can do so by link to PHP Info on the MAMP and XAMPP Welcome Pages.

PHP

PHP stands for PHP: Hypertext Preprocessor. It's a rather ugly name for a very powerful scripting language that's relatively easy to learn. You can use PHP in your websites for a wide range of tasks, such as processing online forms, uploading files.

What does the phrase "PHP was designed as an embedded language" mean?

What that means is that PHP code is often mixed or embedded in HTML markup. This is the HTML markup for a basic feedback form. And here, on lines 28 and 30, are PHP commands that wrap around this paragraph.

How PHP work?

When someone visits a website, the browser sends a request to the web server. With a static webpage that just consists of HTML, CSS images, and maybe JavaScript, the server simply responds by sending all the necessary files. However, if you use PHP in your webpages, the service sends the page to the PHP engine for processing before sending the response to the browser. And if a database is involved, the PHP engine is responsible for sending the request to database and processing the results. All this usually takes only a fraction of a second, so there's no noticeable delay.

When viewing PHP pages

When viewing PHP pages, it's important to remember the following • the PHP code must be processed by the web server. If you've got into the habit of double-clicking HTML pages to view them locally, that won't work with PHP. What will happen is that you'll either just see the raw code or you'll be prompted to download the file. • So, it's important to remember that the server is running. It may sound obvious, but it's easy to forget, particularly in the early stages. • And you should always view the page using a URL. So, in most cases, this will be HTTP:// local host, followed by wherever you've put the file. Remember those basic points, and you'll soon discover that PHP isn't all that difficult to learn and is great fun to use.

PHP Usage

When working with images, you can automatically generate thumbnails or watermarks. PHP can also read and write files directly on your server. And one of its most important uses is communicating with the database. Most of the time, PHP is used with the open source MySQL database. But it also works with all leading databases. There's much more that you can do with PHP. But in this introductory workshop, I'm going to explain the basic structure of the language, and then show you how to process a contact form and email its contents.

Where is the Server Root on EasyPHP?

in EasyPHP, it is at \EasyPHP\www

Where is the Server Root on IIS?

in IIS, it is at \inetpub\wwwroot

What feature to look for in a PHP text eidtor?

• PHP syntax checker (to make it easy to spot mistakes in your code) • PHP syntax coloring (to highlight the different parts of the language, this also helps identify mistakes) • PHP code hints (to remind you of how to use built in and custom functions) • Line Numbering • A "balance braces" feature (to identify matching opening and closing braces)

What do you need to get started with PHP?

• PHP-enabled web server. • remote server, the one that hosts your website, needs to support PHP. And you could use it for testing and development. But it's not a good idea. • It's much better to set up a local testing environment. Working locally is both safer and quicker. You don't need to keep uploading your files every time you make a change. Even when you become more experienced, you'll appreciate being able to develop offline in your local testing environment. • You also need a suitable script editor to write your PHP code. PHP is written in plain text like HTML and CSS. So, you don't need anything special, but I'll offer some suggestions. • For your local testing environment, I recommend using XAMPP for Windows or MAMP on Mac OS X. Both provide you with all the necessary components.


Kaugnay na mga set ng pag-aaral

Foundations Exam 1 Chapter 20 PrepU

View Set

Types of Life Insurance Policies

View Set

13 - Oracle Sequence and trigger

View Set

Social Studies 1102: Self Test 1

View Set

Accounting 4A: Chapter 9, 11-14 Quiz

View Set