ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing in PHP
  • Overview
  • What is a PHP site?
  • How to?
  • Creating a PHP project
  • The PHP RAD
  • Typing code in PHP
  • Testing a PHP project
  • Deploying a PHP site
  • PHP pages with or without context
  • Special case for PHP pages without context
  • Limitations
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview

What is a PHP site?

A PHP site is a site entirely compiled in PHP.
A PHP site corresponds to ".php" pages generated from WEBDEV. This type of site requires a PHP engine in order to be run.
This type of site can use a database. For more details, see Handling data files in PHP.
Why develop a PHP site with WEBDEV?
It may be useful to develop some sites (especially small ones) using PHP to make it easy to host them at no cost. When deploying a PHP site, the WEBDEV engine is not required but a PHP engine must be installed on the server.
Generating a PHP site with WEBDEV
WEBDEV allows you to create PHP sites without prior knowledge. The site is developed in WLanguage like any other WEBDEV site.
You can also enter your PHP code directly.
A syntax and lexical analysis is now available for PHP and JavaScript code.
When the pages are generated, the WEBDEV pages and the WLanguage functions are automatically converted to PHP.
Remark: Prerequisite:
  • PHP 5 servers: Minimum recommended version: version 5.6.
  • PHP 7 servers: Minimum recommended version: version 7.0.22.
  • PHP 8 servers: Minimum recommended version: version 8.0.10.
  • Optional MySQL database.
How to?

Creating a PHP project

When creating a project, the wizard prompts you to choose the type of site you want to create. Simply select "PHP site" and follow the wizard. Once your project is created, you develop in WLanguage like for any WEBDEV site.
Remark: The number of WLanguage functions that can be used in a PHP project is limited in this version. This number of functions will increase in forthcoming versions.
You can change the type of generation of a project at any time:
  1. Open the project description window: on the "Project" tab, in the "Project" group, click "Description".
  2. If necessary, change the type of site to PHP:
  3. Validate.
Once the project is configured as a PHP project, all the tools available in WEBDEV are automatically configured for this type of project:
  • The window RAD or the full RAD is specific to a database handled by a PHP site.
  • The compilation of the project indicates whether your project contains functions or controls that cannot be used in PHP. A purple message is displayed in the "Compilation errors" pane.
  • The pages are generated as ".php" files
Remark: It is recommended to create a new PHP project to develop a PHP site rather than converting a WEBDEV site to PHP.

The PHP RAD

As with any WEBDEV project associated with an analysis, you can use the RAD methodology to generate the pages of your PHP site.
You can create pages with preset forms, tables, etc. The PHP RAD takes into account all the specific features of the PHP generation (controls, events and functions that can be used in a WEBDEV site generated in PHP).
The PHP pages generated with the RAD methodology use the WLanguage SQL and HFSQL functions. The connection to the database is established with SQLConnect via ODBC.

Typing code in PHP

The codes run on the server are represented by a Yellow or Pink bar in the code editor.
  • Yellow bar = WLanguage: the WL symbol is displayed on the code header.
  • Pink bar = PHP: the PHP symbol is displayed on the code header.
To switch from yellow code (WLanguage) to pink code (PHP), simply click the WL symbol in the code header. Conversely, click PHP to switch to WLanguage. When the PHP page is saved, the WLanguage code is automatically converted to PHP.

Testing a PHP project

The directory used when testing a PHP project via the GO icon is "<ProjectName>_WEB" and not the "EXE" directory, which is automatically created with the PHP project.

Deploying a PHP site

PHP sites are deployed via WDDeploy.
Caution: To deploy a PHP site, the directory of the sessions must be located and defined at the hosting provider.
PHP pages with or without context
Two types of PHP pages can be generated:
  • PHP pages with context.
    In this mode, global variables are shared between all the project pages.
    By default, all new PHP pages are created with context (the "Generate PHP pages with context" option is checked in the "General" tab of the page description window).
  • PHP pages without context (uncheck the "Generate PHP pages with context" option in the "General" tab of the page description window).
    In this mode, pages exchange data via cookies or command line parameters.

Special case for PHP pages without context

The project initialization event can be executed before the page global declarations event. This makes it possible to declare global variables or open a database connection in the project initialization event, for example.
Caution: Global variables are reinitialized each time the page is displayed or refreshed.
To get this operating mode, simply:
  1. Open the page description window (on the "Page" tab, in the "Edit" group, click "Other actions" and select "Page description").
  2. In the "General" tab:
    • Make sure that the page has no context (the "Generate PHP pages with context" option must be unchecked).
    • Check "Run project PHP code each time the page is displayed".
Remarks:
  • In a project from WEBDEV 14 (or an earlier version), this option is not enabled by default.
  • In a new PHP WEBDEV project (starting with version 15): by default, new pages are have a context.
  • Starting with version 15, when an Active WEBDEV Page or a dynamic page is converted to PHP, this option is enabled by default for better compatibility.
Limitations
The following elements are not available in the PHP generation:
  • Unicode strings.
  • "GOTO" statement.
  • Object-Oriented Programming (OOP).
  • WLanguage handles reals with higher precision (higher number of decimal places) than PHP.
Several WLanguage functions are available. For more details, see Functions available in PHP.
Only the Latin-1 (ISO-8859-1) character set is supported, which includes the following languages: Albanian, German, English, Basque, Catalan, Danish, Scottish Gaelic, Spanish, Faroese, Finnish (except for the Š and š characters), French (except for the Ÿ, œ and Œ characters), Icelandic (except for the „ and " characters), Irish Gaelic, Italian, Dutch, Norwegian, Portuguese, Romansh and Swedish. The Afrikaans and the Swahili are also supported.
Remark: Prerequisite:
  • PHP 5 servers: Minimum recommended version: version 5.6.
  • PHP 7 servers: Minimum recommended version: version 7.0.22.
  • PHP 8 servers: Minimum recommended version: version 8.0.10.
  • A MySQL database is optional.
Related Examples:
WW_PayPal_PHP Training (WEBDEV): WW_PayPal_PHP
[ + ] This PHP example, powered by WEBDEV, explains how to propose a secured payment with the PayPal solution in your WEBDEV PHP sites.
It explains how to:
- include a PayPal payment button in a page,
- specify the payment information to PayPal,
- define a page for validating the payment,
...
WW_Forum_PHP Complete examples (WEBDEV): WW_Forum_PHP
[ + ] This example proposes the main features of a user forum (creation of forums, topics and messages, moderator, search, etc.)

Some of the features used by WW_FORUM_PHP:
- Rich control
- AJAX
-...
WW_Blogs_php Complete examples (WEBDEV): WW_Blogs_php
[ + ] This example is a PHP site created with WEBDEV for managing blogs.
A blog is a log or a diary on an Internet site.
It can be consulted by everyone and everyone can write his own comments.
The author of the blog writes messages whenever he wants to.
You have the ability to format the text, to include images, notes, and so on.
Furthermore, each blog can be exported in RSS.
WW_Association_PHP Complete examples (WEBDEV): WW_Association_PHP
[ + ] This example presents an associative site in WEBDEV PHP.
This site includes 2 main sections:
- the visitor section, accessible to all.
- the management section, reserved to the members of the association.  
 
This site is used to present the news, the photo galleries, the presentation of the association...
The members of the association can manage their news, their photos, exchange some messages and access the classified adverts...
The administrator manages the site as well as the members of the association.
Minimum version required
  • Version 9
Comments
Click [Add] to post a comment

Last update: 09/04/2023

Send a report | Local help