PHP Support with Expression Web 3

PHP is one of the essential Web technologies and we’ve supported PHP in Expression Web for several versions now. With Expression Web 3, you can create PHP pages, embed PHP code in your HTML pages, or a combination of both methods.

Expression Web 3 supports PHP code coloring, Intellisense, the insertion of PHP code snippets, PHP includes, and previewing of the PHP page with the included development server. And, if you have either IIS 6 or IIS 7 installed on your Web server, you can enable FastCGI for better PHP performance.

Pointing to the PHP Executable

Before you write any PHP code, make certain that the path to the PHP executable is set in Expression Web.

1. Click the Tools>Applications Options menu pick.

2. Browse to where the PHP executable is installed and click OK.

Expression Web 3 Settings

Creating a PHP Page

1. Now, click File>New>PHP to create an untitled PHP page.

2. Between the body tags, type

                     <HTML>
                      <HEAD></HEAD>
                      <BODY>
                            <?php echo ("Hello World") ?>
                      </BODY>
                    </HTML>
                

Previewing PHP Pages with the Built-In Developer Server

To test your PHP page, you need a Web server, either local or remote. The disadvantage of using a remote Web server is that it takes time to publish your changes so that you can see the results. And local Web servers, such as Apache or IIS, can be a challenge to correctly configure.

Expression Web 3 includes a built-in development server that you can use to preview both PHP and ASP.NET pages. To take advantage of this all you need to do is specify the location on your hard disk of the PHP runtime to use for processing PHP content in your web pages.

But the real strength of Expression Web’s development server is that you can use it to preview your pages with a variety of installed browsers at a variety of screen resolutions.

1. Choose File>Preview in Browser> to see a list of your installed browsers that you can use to preview the page.

2. Choose one of the browsers. You should see a preview similar to the following:

Expression Web 3 PHP Previews

PHP Includes

Expression Web supports PHP includes to incorporate common elements on multiple pages in your site. Incorporating includes in every page is as easy as saving the common elements in a PHP file and adding the following line of code:

                     <?php include (‘Name_of_include_file.php’); ?>

Even though the elements are included in a separate file, Expression Web displays the content in its Design View.

IntelliSense for PHP

With IntelliSense, whenever you are in a code block, IntelliSense will display all of your relevant choices, as for example a list of properties (or attributes), methods or events. IntelliSense is especially helpful for built in PHP functions since it will show the list of required parameters along with their appropriate data types.

https://blogs.msdn.com/photos/mibach/images/9910923/original.aspx 

PHP code Snippets

PHP snippets are common PHP code items that can be inserted into your PHP page by choosing Insert>PHP and then the snippet that you want to add. For example, Expression Web can insert the entire PHP include shown above if you choose it from the Insert menu and then navigate to the file which you want to include.