Using PHP with FrontPage 2003

Applies to
Microsoft Office FrontPage® 2003

Microsoft Office FrontPage 2003 Inside Out book cover


This article was adapted from Microsoft Office FrontPage 2003 Inside Out by Jim Buyens. Visit Microsoft Learning to learn more about this book.

You can use PHP to build sophisticated and complex Web applications and external and internal business channels, such as e-commerce sites, corporate portals, and intranets. Microsoft offers an alternative to scripting with PHP — ASP.NET — which is described in more detail later in this article. As might be expected, FrontPage supports the Active Server Pages (ASP) and ASP.NET technologies more completely than it does PHP. However, if you reconfigure certain settings, FrontPage and PHP can work together.

What is PHP?

PHP is a server-side scripting language (scripting language: A simple programming language designed to perform special or limited tasks, sometimes associated with a particular application or function.) that you can embed into HTML when you create dynamic Web pages. PHP is an open-source product that you can use, alter, and redistribute without charge. Originally PHP stood for Personal Home Page tool, but over time it has evolved to stand for PHP: Hypertext Preprocessor.

In general, dynamic Web pages are pages that interact with users, so that each site visitor sees customized information. In the case of PHP, dynamic also means that data is pulled from a database. Dynamic Web applications are prevalent in commercial (e-commerce) sites, where the content displayed is generated from information that is accessed from a database or other external source.

PHP's syntax is similar to that of C and Perl, making it easy to learn for anyone with basic programming skills. PHP supports only partial encapsulation (such as support for declaring methods and fields in the class) and partial polymorphism (no overloading, no abstraction). With PHP, there is no concept of private, public, or protected functions in classes as well as in the overloading.

Create pages that contain PHP scripts

When you use PHP with FrontPage 2003, you create the overall Web page design and insert any fixed elements by using Design view in FrontPage. You can then write the HTML code that contains the variable portion of each PHP response in Code view. Of course, when you are laying out the Web page design, you may want to create placeholders to indicate where the variable output should appear, so that you can easily locate where you want to add the PHP script.

PHP scripts must reside in an executable directory. For reasons of security and resource consumption, many server administrators tightly control access to such directories. If you do not administer your own Web server, you need permission from the server administrator to run server-side scripts.

Change settings in FrontPage 2003

Before you can use PHP with FrontPage 2003, you must make the following changes to settings in FrontPage:

ShowDisable features that require the FrontPage Server Extensions

If the Web server that runs your PHP pages has the FrontPage Server Extensions from Microsoft installed, do the following:

  1. On the Tools menu, click Page Options, and then click the Authoring tab.
  2. Under FrontPage and SharePoint technologies, clear the SharePoint Services and Browse-time Web Components check boxes.

ShowDisable features that create ASP or ASP.NET code

If the Web server that runs your PHP pages can also run ASP, do the following:

  1. On the Tools menu, click Page Options, and then click the Authoring tab.
  2. Under Browsers, clear the Active Server Pages check box.

ShowEnable and use ASP-style <% %> code delimiters

Do the following:

  1. Open the php.ini (php.ini: The master configuration file for PHP that you can customize to help you control the way PHP works on your site.) file on the Web server, and set asp_tags="1".
  2. Use ASP-like <% and %> tags instead of the <? php?> tags. This stops FrontPage from reformatting your PHP code.

 Note   As an alternative, you can use <script language="php"> and </script> tags instead of <? php?> tags.

ShowConfigure PHP file extensions to open in Design view

  1. On the Tools menu, click Options, and then click the Configure Editors tab.
  2. In the Extensions list, locate and select the file extension that you want to use.
  3. In the Editors list, select FrontPage (Open as HTML).
  4. Click Make Default.

If the extension that you want does not appear, you must add it.

ShowHow?

  1. Click the New Extension button (or press ALT+N), located above the Extensions list.
  2. In the Open With dialog box, type the file extension that you want in the Extension box.
  3. Select FrontPage (Open as HTML), and then click OK.

ASP.NET — an alternative to PHP

If you are using PHP with FrontPage and find that it prevents you from accomplishing what you want in your Web site, you might consider using ASP.NET instead.

ASP.NET is part of the Microsoft .NET Framework, which is a feature of Microsoft Windows®. Unlike PHP, ASP.NET is not a language or a parser but rather a set of technologies in the Microsoft .NET Framework for building Web applications and XML Web services.

Microsoft ASP.NET pages run on the server like PHP and generate markup, such as HTML, WML, or XML, which is sent to a desktop or to mobile applications. ASP.NET provides a robust, object-oriented, event-driven programming model for developing Web pages, while still maintaining the simplicity that PHP developers are accustomed to.

ASP.NET applications are based on a robust Object Oriented Programming (OOP) paradigm rather than a scripting paradigm. This allows for more advanced OOP features, such as inheritance, encapsulation, and reflection.

If you are considering migrating to ASP.NET, in most cases it is not very complex for simple to small applications. Due to underlying architectural differences as well as the ASP.NET OOP paradigm, more sophisticated and complex applications must be well planned to take advantage of the more rigorous separation of display from logic and data in ASP.NET, as well as its time-saving, built-in functionality that significantly reduces the amount of code necessary to perform comparable tasks.

For more information about ASP.NET, see the following:

 
 
Applies to:
FrontPage 2003