echopage (function)

Last updated: Mon, Apr 17, 2023 8:14 am
Return to Knowledgebase

Purpose

Echoes page name when given a page id

Location

users/helpers/permissions.php

Parameters

# Parameter Data Type Required Description
1 $id integer Yes represents the ID of the page whose content is to be retrieved from the database

Returns

Data Type Description of Returned Data
string The function does not explicitly return any value, but instead uses the echo statement to output the content of the specified page to the page for display. If the ID matches a page in the pages table, the function will output the content of that page as a string. If the ID does not match any pages in the table, the function will output the message "Unknown" as a string.

Example

echopage(1)

Further Documentation:

The function first creates an instance of the UserSpice database class (DB::getInstance()) and then executes a SQL query to select the page column from the pages table where the id matches the given $id. The function then checks if any results were returned, and if so, it outputs the content of the page column using the echo statement. If no results were returned, it outputs a message stating that the page is unknown.

Here is an example of how to use the echopage function:

Suppose you have a website with several pages, and you want to display the content of a specific page based on its ID. You can use the echopage function like this:

echopage(2);


This will output the content of the page with an ID of 2, assuming that the ID exists in the pages table. If the ID does not exist, the function will output the message "Unknown".

You can also use a variable to specify the ID, like this:

$page_id = 3;
echopage($page_id);

This will output the content of the page with an ID of 3.