Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Programming Help > PHP Programming Help

PHP Programming Help Post any question relating to PHP Programming here and hopefully someone can help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2005-07-15, 08:35 PM
Junior Member
 
Join Date: Jul 2005
Posts: 3
erikmeyer
Default

OK, so I am a total noob to PHP (and pretty much to HTML). I am trying to implement a simple PHP class, but am facing a roadbloack. By simply including or requiring my simple class, my page is broken in the browser (and incidentally, fails to validate). The class simply has 3 public properties, no functions as of yet. I have added the class to the php code of a page that works perfectly and validates to XHTML strict...until i include the class, in any of the following fashions:

1. include "box.php";
2. include( "box.php" );
3. require - with and without parenthesis
4. require_once - with and wothout
5. ..... you get the picture

Any of these one liners breaks my page, and I can't figure why. I tried instantiating the class into an object, to no avail. Is there some secret about using classes in PHP that I need to know? My books and online docs on the subject mention nothing that I find readily.

A couple of notes: the box.php code resides in the same path as the index.php code that tries to call it and the actual text of the class is shown below.

<?php

class box
{
public $bgcolor;
public $txtcolor;
public $brdrcolor;
}

?>


Any help would be most appreciated.

Erik
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2005-07-16, 10:45 AM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

I assume your include/require is happening inside of the PHP tags?

Also, remember you have to instatinate the class, just declaring it wont run it.
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote
  #3 (permalink)  
Old 2005-07-16, 02:16 PM
Junior Member
 
Join Date: Jul 2005
Posts: 3
erikmeyer
Default

Yes, my inlcude/require statements are inside of php tags. My issue is that as soon as I put in the inlcude/require statement, my html breaks, with oor without instantiating the class into an object. I'm concerned that the html is broken.

Erik
Reply With Quote
  #4 (permalink)  
Old 2005-07-18, 05:32 PM
Junior Member
 
Join Date: Jul 2005
Posts: 3
erikmeyer
Default

OK, probllem solved. My host had led me to believe that PHP5 was running on the server when, in fact, it was not. Changing the public keyword to var fixed the problem.

Score one more for the Nooobs. Should've reviewed the php info before I got started.

Erik
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:03 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.