473,385 Members | 1,400 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,385 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 7442
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.