Irish SEO,  Marketing & Webmaster Discussion

 

PHP, OOPS! data typing

This is a discussion on PHP, OOPS! data typing within the Coding Help forums, part of the Webmaster Help category; Hi, I've decided to move to OOP after my procedural coding background (for shame, I know!). I am now studying ...


Go Back   Irish SEO, Marketing & Webmaster Discussion > Webmaster Help > Coding Help

Register Forum Rules FAQDonate Members List Calendar Search Today's Posts Mark Forums Read


Notices

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 23-08-2007, 12:34 PM
Frontpage User
 
Join Date: Aug 2007
Location: Dublin
Posts: 13
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Mike will become famous soon enough
Default PHP, OOPS! data typing

Hi,

I've decided to move to OOP after my procedural coding background (for shame, I know!). I am now studying a PHP 5 OOP book but because it's not a very recent one (PHP 5 Objects, Patterns, and Practice - Apress) I've run into the problem of string types not being automatically recognised/converted when returning variables from a constructer within a class. The error I'm getting is:

'Object of class ClassName could not be converted to string'

Well, I know what the problem is, PHP will not do the typeing for you on variables as it once did. I've Googled endlessly for a solution but the fixes are often wrapped in long flame wars between those who agree with PHP's new treatment of variables and those who don't. This makes it difficult to get a solution. One solution I've seen is to use the __toString() function. This is not recognised by my version of PHP. Do I need to upgrade it or what? Does anyone have a simple method of converting the variables to their intended type or a best practice for returning the variables correctly?

cheers,

Mike
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 23-08-2007, 05:57 PM
daviddoran's Avatar
Wannabe Geek
Recent Blog: iMSISS
 
Join Date: Aug 2006
Location: Meath, Ireland
Posts: 342
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
daviddoran will become famous soon enough
Default

Snippet of code please?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 24-08-2007, 02:44 PM
Frontpage User
 
Join Date: Aug 2007
Location: Dublin
Posts: 13
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Mike will become famous soon enough
Default

erm, for some reason I can't reproduce the error now! Thanks for the reply and I'll put some code in here if I get it again (and I will get it again!)

cheers,

Mike
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
data, oops, php, typing

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
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
PHP includes - correct formatting EdenWeb Coding Help 6 16-08-2007 12:02 AM
php mysql repeat region Keewee6 Coding Help 7 14-08-2007 05:50 PM
PHP mySQL Problem!? ziycon Server / Technical Administration Tips and Queries 1 15-07-2007 08:31 PM
WTF - Some PHP Obfuscation. daviddoran General Chat 8 20-02-2007 05:45 PM
PHP on windows louie Coding Help 20 22-02-2006 06:25 PM


Sponsored links

Paid On Results


All times are GMT +1. The time now is 05:04 AM.


Powered by: vBulletin Version 3.7.3, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Hosted in Ireland by Blacknight - Test your ISP |Irish Hosting Directory| Armchair.ie|Logo by Eden Web Design|Avatars by Afterglow |Latest Blog Entries | VPS HostingAd Management by RedTyger

Search Engine Friendly URLs by vBSEO 3.2.0