answersLogoWhite

0


Best Answer

To create a PHP class it is pretty simple, I will show you how to create a very basic class in an example below.

<?php

// the class

class myBasicClass {

// a function to add 2 numbers together and return the result

function add($num1, $num2) {

$result = $num1 + $num2;

return $result;

}

}

// load up the class

$myBasicClass = new myBasicClass;

// output the result

echo $myBasicClass->add(5, 10); // outputs the result 15

?>

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you create a PHP class?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you install crystal reports for php?

how to create report in php


How do you create an area of a webpage to display PHP results?

PHP code blocks start with &lt;?php and end with ?&gt;.


How do you create a PHP script?

To create a PHP script all you have to do is create a new file, then save the file as "filename.php". It must have a .php file extension.After that open the file and put in the PHP tags like shown.Then you write your PHP script within those tags and upload to your web space and check it out.


PHP case sensitivity refers to what?

PHP case sensitivity refers to that in coding it matters if the code is in capital letters. Case sensitivity specifically in PHP refers to variables, constants, array keys, class properties, and class constants. Some items in PHP that are not case sensitive are functions, class constructors, class methods, and keywords and constructs.


Why do we use Php?

PHP is an Open Source Scripting Language. We can create Web Pages and Web Applications using PHP.


What is php image size?

PHP can create images of different sizes. It depends on a particular image.


How do you create a text editor in PHP?

Well it got nothing to do with PHP, you going to need JavaScript to do that :)


What is new in PHP?

PHP is a recursive acronym for "PHP: Hypertext Preprocessor" created by The PHP Group. PHP is a widely used server-side scripting language and the general purpose of PHP is to create dynamic Web Pages. For more information, visit the PHP website.


How do you create a web mail script using PHP?

You can use phpMailer() Or, you can use mail() PHP function to send emails via PHP script.


What is the way to create a function in PHP?

function function_name() { .................... }


How do you write themes in PHP?

You can use Cascading Style Sheets (CSS) to create website themes for your PHP website.


What is the present social status of the Philippines?

The Philippines, is 12% Class ABC, 49% D and 39% E as of April 2010. Class A - Upper Class - executives, presidents, CEOs (&gt;Php 100,000 / month) Class B - Upper Middle Class - professionals (Php 50,000-100,000 / month) Class C - Middle Class - white-collar jobs (Php 15,000-50,000 / month) Class D - Lower Middle Class - blue-collar/clerical jobs (Php,8,000-15,000 / month) Class E - Lower Class - living below the poverty line (&lt;Php 8,000 / month)