473,396 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Simple example of how to wirite php using classes

121 100+
hi,

hello friends, i know basic php, i want to use advanced php classes is anybody knows how to write simple example using php classes.

i want to use this one for listbox::onChange class.

regards
shiva
Aug 24 '07 #1
4 7443
Atli
5,058 Expert 4TB
Hi.

Check out Classes and Objects at the PHP.net Manual.

The class you mentioned, listbox, does not exists in PHP.
It looks more like a .Net class. Where did you find it?
Aug 24 '07 #2
gregerly
192 Expert 100+
VERY SIMPLE CLASS

class.php

[PHP]class myClass{

var $message;

function echoMessage(){
echo $this->message;
}

}[/PHP]

index.php

[PHP]include("./path/to/the/class.php");
$class=new myClass;

$class->message = "Hello World";
$class->echoMessage();

//Results in "Hello World"[/PHP]

This is an extremely simple example of OOP and using classes in PHP.

Greg
Aug 24 '07 #3
pbmods
5,821 Expert 4TB
Or in PHP 5:

Expand|Select|Wrap|Line Numbers
  1. class myClass
  2. {
  3.      protected $message;
  4.  
  5.      public function __construct()
  6.      {
  7.           $this->message = 'Hello, World!';
  8.      } 
  9.  
  10.      public function echoMessage()
  11.      {
  12.           echo $this->message;
  13.      }
  14. }
  15.  
Aug 24 '07 #4
gregerly
192 Expert 100+
Or in PHP 5:

Expand|Select|Wrap|Line Numbers
  1. class myClass
  2. {
  3.      protected $message;
  4.  
  5.      public function __construct()
  6.      {
  7.           $this->message = 'Hello, World!';
  8.      } 
  9.  
  10.      public function echoMessage()
  11.      {
  12.           echo $this->message;
  13.      }
  14. }
  15.  
well done good sir :)
Aug 24 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Droolboy | last post by:
I'm trying to build a fairly small (max. 10 different pages) site using php, and it's becoming obvious that I need some kind of model view separation. Having done a few searches, I've come...
3
by: Patchwork | last post by:
Hi Everyone, Please take a look at the following (simple and fun) program: //////////////////////////////////////////////////////////////////////////// ///////////// // Monster Munch, example...
3
by: mescaline | last post by:
//Consider the simple program with inheritance, plain init for A, copy ctr for B #include <iostream> using namespace std; class Base{ public: Base(){cout << "Base, default" << endl;}...
7
by: Mark Prenter | last post by:
Hi all, I'm fairly new to .NET and I haven't done much in C++ before, nothing complex anyway, but I have a pretty good understanding of programming in general. What I'm trying to do is create a...
17
by: RSH | last post by:
I am really trying to grasp the concept of OOP as it applies to C#. I am looking at trying to set up a simple Employee Class but I am having trouble conceptualizing what this class should look...
26
by: nyathancha | last post by:
Hi, How Do I create an instance of a derived class from an instance of a base class, essentially wrapping up an existing base class with some additional functionality. The reason I need this is...
8
by: Devon Null | last post by:
I was wondering if there is a container (i.e. a vector) that can hold data structures of differing sizes. I was thinking of something along the lines of a container of classes. Think of a backpack...
30
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
10
by: Phillip Taylor | last post by:
Hi guys, I'm looking to develop a simple web service in VB.NET but I'm having some trivial issues. In Visual Studio I create a web services project and change the asmx.vb file to this: Imports...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.