We will create the StatusPoster.php
file and the class skeleton using the NetBeans code template, and to create methods within the class, we will use the function
template as well. We will create a MySQL database connection using a PDO inside the class constructor, so that the database connection is created along with the object instantiation and getStatusPosts()
method to fetch the status posts from the table.
1. From the Projects pane, right-click on project name
chapter3
, select New | PHP File..., and name the fileStatusPoster
, as shown in the following screenshot:2. Click on Finish to have the file added to our project and automatically opened in the editor. You will see PHP starting and ending tags placed inside the file.
3. In order to create the PHP class skeleton, we will use PHP code templates. We type
cls
and press the Tab key to obtain the class skeleton with a constructor inside, as follows:4. In...