Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-23-2010, 02:51 PM   PM User | #1
mike182uk
Regular Coder

 
Join Date: May 2008
Posts: 135
Thanks: 13
Thanked 10 Times in 10 Posts
mike182uk is an unknown quantity at this point
class variable not letting me use fullstop

hi there, i'am having a problem with using the the fullstop to concat 2 stings in a class variable.

PHP Code:
define("TEST""hello");

class 
myclass
{
    var 
$myvar TEST "world";

is there any reason why the above wouldnt work? if so how would i get around it?

i get an error but i am using an IIS server and for some reason it wont let me turn on php errors. sorry.
mike182uk is offline   Reply With Quote
Old 01-23-2010, 03:16 PM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
You can't use an expression or return value of a function to a class member while decalration. You'd need to move that code into constructor, like
PHP Code:
class myclass
{
    var 
$myvar;
   function 
__construct(){
   
$this->myvar=TEST "world"
   }

__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Users who have thanked abduraooft for this post:
mike182uk (01-23-2010)
Old 01-23-2010, 03:24 PM   PM User | #3
JAY6390
Regular Coder

 
Join Date: Dec 2009
Location: UK
Posts: 495
Thanks: 0
Thanked 58 Times in 58 Posts
JAY6390 is on a distinguished road
This doesn't work no matter what server you use. You can't concatenate strings when defining properties of a class
__________________
My site: JayGilford.com
Resources:
PHP Pagination Class | Getting all page links | Handling PHP Errors properly
If you like a users help, show your appreciation with the rep and thanks buttons :)
JAY6390 is offline   Reply With Quote
Old 01-23-2010, 03:39 PM   PM User | #4
mike182uk
Regular Coder

 
Join Date: May 2008
Posts: 135
Thanks: 13
Thanked 10 Times in 10 Posts
mike182uk is an unknown quantity at this point
hey abduraooft thanks alot for that, i thought i was just making a syntax error, i didnt even know about the constructor. anyways thanks alot that worked great! i'll go and read up on constructors
mike182uk is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


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


Advertisement
Log in to turn off these ads.