• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 08:11
CEST 14:11
KST 21:11
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Code S Season 1 - RO8 Preview4[ASL21] Ro8 Preview Pt2: Progenitors8Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun13[ASL21] Ro8 Preview Pt1: Inheritors16[ASL21] Ro16 Preview Pt2: All Star10
Community News
Maestros of The Game 2 announcement and schedule !7Weekly Cups (April 27-May 4): Clem takes triple0RSL Revival: Season 5 - Qualifiers and Main Event12Code S Season 1 (2026) - RO12 Results12026 GSL Season 1 Qualifiers25
StarCraft 2
General
Code S Season 1 - RO8 Preview Behind the Blue - Team Liquid History Book Weekly Cups (April 27-May 4): Clem takes triple Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Code S Season 1 (2026) - RO12 Results
Tourneys
Sea Duckling Open (Global, Bronze-Diamond) Maestros of The Game 2 announcement and schedule ! GSL Code S Season 1 (2026) RSL Revival: Season 5 - Qualifiers and Main Event Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players
External Content
Mutation # 524 Death and Taxes The PondCast: SC2 News & Results Mutation # 523 Firewall Mutation # 522 Flip My Base
Brood War
General
Quality of life changes in BW that you will like ? BGH Auto Balance -> http://bghmmr.eu/ RepMastered™: replay sharing and analyzer site Tulbo's ASL S21 Ro8 Post-Review Why there arent any 256x256 pro maps?
Tourneys
Escore Tournament StarCraft Season 2 [ASL21] Ro8 Day 4 [Megathread] Daily Proleagues Small VOD Thread 2.0
Strategy
Simple Questions, Simple Answers Fighting Spirit mining rates What's the deal with APM & what's its true value Any training maps people recommend?
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Daigo vs Menard Best of 10 Path of Exile OutLive 25 (RTS Game)
Dota 2
The Story of Wings Gaming
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread The Letting Off Steam Thread European Politico-economics QA Mega-thread UK Politics Mega-thread Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread McBoner: A hockey love story Formula 1 Discussion
World Cup 2022
Tech Support
streaming software Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
How EEG Data Can Predict Gam…
TrAiDoS
ramps on octagon
StaticNine
Funny Nicknames
LUCKY_NOOB
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1574 users

The Big Programming Thread - Page 612

Forum Index > General Forum
Post a Reply
Prev 1 610 611 612 613 614 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
_fool
Profile Joined February 2011
Netherlands682 Posts
April 13 2015 20:42 GMT
#12221
On April 14 2015 04:56 boon2537 wrote:
I chose to do a simple tic-tac-toe with an A.I. in Lisp as a project for my programming language class. Since I'm a noob with functional stuff, I just abuse progn make life easy for myself. I just hope my professor doesn't mind that too much >.<


Guess what: professors usually don't work that way
"News is to the mind what sugar is to the body"
boon2537
Profile Blog Joined October 2010
United States905 Posts
April 13 2015 21:18 GMT
#12222
On April 14 2015 05:42 _fool wrote:
Show nested quote +
On April 14 2015 04:56 boon2537 wrote:
I chose to do a simple tic-tac-toe with an A.I. in Lisp as a project for my programming language class. Since I'm a noob with functional stuff, I just abuse progn make life easy for myself. I just hope my professor doesn't mind that too much >.<


Guess what: professors usually don't work that way

That's why I'm getting it done early so that I can ask my professor if he's gonna fail me if I turn in that code, haha.
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
April 13 2015 22:50 GMT
#12223
On April 14 2015 06:18 boon2537 wrote:
Show nested quote +
On April 14 2015 05:42 _fool wrote:
On April 14 2015 04:56 boon2537 wrote:
I chose to do a simple tic-tac-toe with an A.I. in Lisp as a project for my programming language class. Since I'm a noob with functional stuff, I just abuse progn make life easy for myself. I just hope my professor doesn't mind that too much >.<


Guess what: professors usually don't work that way

That's why I'm getting it done early so that I can ask my professor if he's gonna fail me if I turn in that code, haha.


I recommend asking him before you do any work that might be pointless.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
April 13 2015 23:48 GMT
#12224
On April 14 2015 04:56 boon2537 wrote:
I chose to do a simple tic-tac-toe with an A.I. in Lisp as a project for my programming language class. Since I'm a noob with functional stuff, I just abuse progn make life easy for myself. I just hope my professor doesn't mind that too much >.<


Just do some project where functional programming makes more sense than OOP. E.g. some people say multi-threaded applications, but I don't know.
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
April 14 2015 01:53 GMT
#12225
On April 13 2015 23:32 sabas123 wrote:

public function setClient($input){
$this->clients[$input];
}



Herein lies your problem as explained before. $this->clients[$input] is nothing more than a pointer to the array index $input. It doesn't set any value.

If you're trying to get an associative array you have to set it this way:


$this->clients[$key] = $value;


If you want a regular array you want to do it this way:


$this->clients[] = $value;


Or this way:


array_push($this->clients, $value);

Time is precious. Waste it wisely.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
April 14 2015 07:42 GMT
#12226
On April 14 2015 10:53 Manit0u wrote:
Show nested quote +
On April 13 2015 23:32 sabas123 wrote:

public function setClient($input){
$this->clients[$input];
}



Herein lies your problem as explained before. $this->clients[$input] is nothing more than a pointer to the array index $input. It doesn't set any value.

If you're trying to get an associative array you have to set it this way:


$this->clients[$key] = $value;


If you want a regular array you want to do it this way:


$this->clients[] = $value;


Or this way:


array_push($this->clients, $value);


ow ye your rightT_T

I have this in my setters now

$this->clients[]=$value;


I think it has something to do with the scope of the variable, since it will only return the value from the method where I give it an extra value.
The harder it becomes, the more you should focus on the basics.
Acrofales
Profile Joined August 2010
Spain18289 Posts
April 14 2015 09:50 GMT
#12227
On April 14 2015 16:42 sabas123 wrote:
Show nested quote +
On April 14 2015 10:53 Manit0u wrote:
On April 13 2015 23:32 sabas123 wrote:

public function setClient($input){
$this->clients[$input];
}



Herein lies your problem as explained before. $this->clients[$input] is nothing more than a pointer to the array index $input. It doesn't set any value.

If you're trying to get an associative array you have to set it this way:


$this->clients[$key] = $value;


If you want a regular array you want to do it this way:


$this->clients[] = $value;


Or this way:


array_push($this->clients, $value);


ow ye your rightT_T

I have this in my setters now

$this->clients[]=$value;


I think it has something to do with the scope of the variable, since it will only return the value from the method where I give it an extra value.

That doesn't make much sense. You will have to post more of the code, because what manitou and I posted should work. If it doesn't, you are either messing with the variable in some other method, or you are not using our code correctly.
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
April 14 2015 11:43 GMT
#12228
Possible error is not giving the setter a required parameter:


// this is bad
public function setVal()
{
$this->vals[] = $val;
}

// this is good
public function setVal($val)
{
$this->vals[] = $val;
}
Time is precious. Waste it wisely.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
April 14 2015 12:38 GMT
#12229
On April 14 2015 20:43 Manit0u wrote:
Possible error is not giving the setter a required parameter:


// this is bad
public function setVal()
{
$this->vals[] = $val;
}

// this is good
public function setVal($val)
{
$this->vals[] = $val;
}

I had that aswell but apperntly it doesn't matter, even if I hard code it the value it doesn't work.

The harder it becomes, the more you should focus on the basics.
Acrofales
Profile Joined August 2010
Spain18289 Posts
April 14 2015 12:54 GMT
#12230
On April 14 2015 21:38 sabas123 wrote:
Show nested quote +
On April 14 2015 20:43 Manit0u wrote:
Possible error is not giving the setter a required parameter:


// this is bad
public function setVal()
{
$this->vals[] = $val;
}

// this is good
public function setVal($val)
{
$this->vals[] = $val;
}

I had that aswell but apperntly it doesn't matter, even if I hard code it the value it doesn't work.


Post your code, because something is wrong. If it's big, spoiler it, but if you don't show us what is wrong, we cannot help.

If you happen to be using a (very) old version of PHP, things might be going wrong. Before PHP 5.0, the object model was basically non-existent, so if for some strange reason you are using a PHP version < 5, everything we have been saying could be wrong (and you should upgrade your PHP version). Using anything older than 5.3 is (strongly) not recommended, and even that is no longer supported. 5.4 is stable, but for new development I wouldn't use anything older than 5.5 for "normal" applications.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
April 14 2015 16:13 GMT
#12231
On April 14 2015 21:54 Acrofales wrote:
Show nested quote +
On April 14 2015 21:38 sabas123 wrote:
On April 14 2015 20:43 Manit0u wrote:
Possible error is not giving the setter a required parameter:


// this is bad
public function setVal()
{
$this->vals[] = $val;
}

// this is good
public function setVal($val)
{
$this->vals[] = $val;
}

I had that aswell but apperntly it doesn't matter, even if I hard code it the value it doesn't work.


Post your code, because something is wrong. If it's big, spoiler it, but if you don't show us what is wrong, we cannot help.

If you happen to be using a (very) old version of PHP, things might be going wrong. Before PHP 5.0, the object model was basically non-existent, so if for some strange reason you are using a PHP version < 5, everything we have been saying could be wrong (and you should upgrade your PHP version). Using anything older than 5.3 is (strongly) not recommended, and even that is no longer supported. 5.4 is stable, but for new development I wouldn't use anything older than 5.5 for "normal" applications.

the getter/setter
https://github.com/sabastiaan/alChat/blob/master/chatroom.php

the place where it gets called
setter on line 85
getter on lin 86
https://github.com/sabastiaan/alChat/blob/master/server.php


The harder it becomes, the more you should focus on the basics.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
April 14 2015 17:15 GMT
#12232
On April 14 2015 08:48 darkness wrote:
Show nested quote +
On April 14 2015 04:56 boon2537 wrote:
I chose to do a simple tic-tac-toe with an A.I. in Lisp as a project for my programming language class. Since I'm a noob with functional stuff, I just abuse progn make life easy for myself. I just hope my professor doesn't mind that too much >.<


Just do some project where functional programming makes more sense than OOP. E.g. some people say multi-threaded applications, but I don't know.

Depends on how you define "makes sense". For multithreading it makes sense because immutability makes life easy there. But that doesn't mean that features will translate naturally into functional code. Many things that are related to mathematics will be much easier to express in functional code.
If you have a good reason to disagree with the above, please tell me. Thank you.
Acrofales
Profile Joined August 2010
Spain18289 Posts
Last Edited: 2015-04-14 17:44:16
April 14 2015 17:43 GMT
#12233
On April 15 2015 01:13 sabas123 wrote:
Show nested quote +
On April 14 2015 21:54 Acrofales wrote:
On April 14 2015 21:38 sabas123 wrote:
On April 14 2015 20:43 Manit0u wrote:
Possible error is not giving the setter a required parameter:


// this is bad
public function setVal()
{
$this->vals[] = $val;
}

// this is good
public function setVal($val)
{
$this->vals[] = $val;
}

I had that aswell but apperntly it doesn't matter, even if I hard code it the value it doesn't work.


Post your code, because something is wrong. If it's big, spoiler it, but if you don't show us what is wrong, we cannot help.

If you happen to be using a (very) old version of PHP, things might be going wrong. Before PHP 5.0, the object model was basically non-existent, so if for some strange reason you are using a PHP version < 5, everything we have been saying could be wrong (and you should upgrade your PHP version). Using anything older than 5.3 is (strongly) not recommended, and even that is no longer supported. 5.4 is stable, but for new development I wouldn't use anything older than 5.5 for "normal" applications.

the getter/setter
https://github.com/sabastiaan/alChat/blob/master/chatroom.php

the place where it gets called
setter on line 85
getter on lin 86
https://github.com/sabastiaan/alChat/blob/master/server.php




The good news is, you chatroom code is working. The bad news is that this probably means something else in your code is broken, if you aren't getting this to work in your full example.

Run this code snippet to test your chatroom:

<?php
require('chatroom.php');

$test = new chatroom();
echo "type of clients: " . gettype($test->getClients()) . "\n";
echo "length of clients: " . sizeof($test->getClients()) . "\n";
for($i = 0; $i < 10; $i++) {
$test->addClient($i);
}
echo "new length of clients: " . sizeof($test->getClients()) . "\n";
foreach ($test->getClients() as $t) {
echo "element: " . $t . "\n";
}

?>


This prints:

type of clients: array
length of clients: 0
new length of clients: 10
element: *some hardcoded test value*
element: *some hardcoded test value*
element: *some hardcoded test value*
element: *some hardcoded test value*
element: *some hardcoded test value*
element: *some hardcoded test value*
element: *some hardcoded test value*
element: *some hardcoded test value*
element: *some hardcoded test value*
element: *some hardcoded test value*

As one would expect. If we change chatroom.php to actually add $input to the array instead of adding your hardcoded string, then it faithfully adds the numbers 0 through 9 to your array, as is expected.


Ropid
Profile Joined March 2009
Germany3557 Posts
April 14 2015 17:46 GMT
#12234
On April 14 2015 08:48 darkness wrote:
Show nested quote +
On April 14 2015 04:56 boon2537 wrote:
I chose to do a simple tic-tac-toe with an A.I. in Lisp as a project for my programming language class. Since I'm a noob with functional stuff, I just abuse progn make life easy for myself. I just hope my professor doesn't mind that too much >.<


Just do some project where functional programming makes more sense than OOP. E.g. some people say multi-threaded applications, but I don't know.

That got me thinking. I feel that might be too optimistic with the multi-threading.

In functional programming, the control structures like "if" and "for" and "while" and even the ";" from the languages you know, you can build your own! Your own stuff will look as if it came with the language. That would apply to Lisp. I've seen someone write that in their production code 25% of lines of code was spent on writing these "macros", so it seems this is not an obscure idea. I guess that you can do that in a language would be neat for adding something that you think will help you for your own parallel stuff.

Then there's an idea "immutability by default" in some languages that will help with parallel stuff, though that's not for Lisp in general. Mutability means you can change the contents of a variable, so that's what you know as normal. This means if you have built yourself a control structure where you want to hide that it's really doing the evaluation in parallel, perhaps something like "foreach x in (...) do (...)", you can't make it perfect and safe. It will break if the code you want to use with it changes something that will influence the same code running in parallel. I think a typical Lisp can't help you with that. There's a popular dialect named "Clojure" that's built around immutability-by-default.

So I'm thinking that's too optimistic to say that functional programming in general is something for multi-threaded stuff. When you write your code, it also needs some added special rules that are invisible in the code and that you just have to keep in mind. But on the other hand, there are some languages where everything you declare is "immutable" and that would help a lot, and those seem to all be functional programming ones?
"My goal is to replace my soul with coffee and become immortal."
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
Last Edited: 2015-04-14 17:58:59
April 14 2015 17:47 GMT
#12235
On April 15 2015 01:13 sabas123 wrote:
Show nested quote +
On April 14 2015 21:54 Acrofales wrote:
On April 14 2015 21:38 sabas123 wrote:
On April 14 2015 20:43 Manit0u wrote:
Possible error is not giving the setter a required parameter:


// this is bad
public function setVal()
{
$this->vals[] = $val;
}

// this is good
public function setVal($val)
{
$this->vals[] = $val;
}

I had that aswell but apperntly it doesn't matter, even if I hard code it the value it doesn't work.


Post your code, because something is wrong. If it's big, spoiler it, but if you don't show us what is wrong, we cannot help.

If you happen to be using a (very) old version of PHP, things might be going wrong. Before PHP 5.0, the object model was basically non-existent, so if for some strange reason you are using a PHP version < 5, everything we have been saying could be wrong (and you should upgrade your PHP version). Using anything older than 5.3 is (strongly) not recommended, and even that is no longer supported. 5.4 is stable, but for new development I wouldn't use anything older than 5.5 for "normal" applications.

the getter/setter
https://github.com/sabastiaan/alChat/blob/master/chatroom.php

the place where it gets called
setter on line 85
getter on lin 86
https://github.com/sabastiaan/alChat/blob/master/server.php


What exactly does this line do?


$system->getRoomList()->getRoom(1)


If this returns new room or new instance of room each time then no wonder it's returning empty arrays if you first get it this way to set some values and then try to do the same with getters.


$setter = $system->getRoomList()->getRoom(1)->addClient();
$getter = $system->getRoomList()->getRoom(1)->getClients();


Should be:


// this preferably set outside of the loop, not inside of it
$chatroom = $system->getRoomList()->getRoom(1);

$chatroom->addClient();
$chatroom->getClients();


Basic DRY principle.

Some other concerns (barring the code formatting, you should work on that - sorry to nitpick like that but I got used to it from work when your merge requests get turned down if you have one space too many or too few):

1. public function sendMessage, this is wrong, you take $msg as an argument and then try to invoke it with $smg, this won't do what you want.

2. In your chatroom class you're operating on class attributes which you don't set in the constructor first, this might end badly for you since you might run into problems with undefined variables (especially that you try and do something with them, treating them as arrays, that's just begging for an undefined index exception).

3. Your 'deleteChatroom' method... You can't unset a class in PHP, especially not from inside of it... You have destructors for that (google php __destruct()). The unset will simply remove a single reference to the object.

4. Why are you doing so much manual memory juggling?

I mean...


while (true) {
$somevar = something;

// do stuff

unset($somevar);
}


You're manually doing something that'll be done automatically anyway.

5. You really shouldn't use die() in smaller methods. It kills the entire application...

6. Just a nitpick, but if your file only contains PHP code (as it should) you shouldn't use the closing tag (?>) at the end of file for security reasons.

Those are the most glaring issues I've found by quickly skimming through the provided files. When I have more time I'll take a more thorough look at them (or maybe Arcofales will).
Time is precious. Waste it wisely.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2015-04-14 19:01:47
April 14 2015 18:51 GMT
#12236
On April 15 2015 02:46 Ropid wrote:
Show nested quote +
On April 14 2015 08:48 darkness wrote:
On April 14 2015 04:56 boon2537 wrote:
I chose to do a simple tic-tac-toe with an A.I. in Lisp as a project for my programming language class. Since I'm a noob with functional stuff, I just abuse progn make life easy for myself. I just hope my professor doesn't mind that too much >.<


Just do some project where functional programming makes more sense than OOP. E.g. some people say multi-threaded applications, but I don't know.

That got me thinking. I feel that might be too optimistic with the multi-threading.

In functional programming, the control structures like "if" and "for" and "while" and even the ";" from the languages you know, you can build your own! Your own stuff will look as if it came with the language. That would apply to Lisp. I've seen someone write that in their production code 25% of lines of code was spent on writing these "macros", so it seems this is not an obscure idea. I guess that you can do that in a language would be neat for adding something that you think will help you for your own parallel stuff.

Then there's an idea "immutability by default" in some languages that will help with parallel stuff, though that's not for Lisp in general. Mutability means you can change the contents of a variable, so that's what you know as normal. This means if you have built yourself a control structure where you want to hide that it's really doing the evaluation in parallel, perhaps something like "foreach x in (...) do (...)", you can't make it perfect and safe. It will break if the code you want to use with it changes something that will influence the same code running in parallel. I think a typical Lisp can't help you with that. There's a popular dialect named "Clojure" that's built around immutability-by-default.

So I'm thinking that's too optimistic to say that functional programming in general is something for multi-threaded stuff. When you write your code, it also needs some added special rules that are invisible in the code and that you just have to keep in mind. But on the other hand, there are some languages where everything you declare is "immutable" and that would help a lot, and those seem to all be functional programming ones?


Yeah, you may be right. I don't do any functional programming other than the one that is included in C#/C++. Just lambdas and LINQ actually. I still find the idea of immutability in functional programming to solve multithreaded problems a bit of a joke because you can have immutability in any other OOP language. Even if you have to use wrappers for that. It shouldn't be so simple to just use immutable data, and frankly, the world isn't static, so I don't like the idea of immutability.

On April 14 2015 04:56 boon2537 wrote:
I chose to do a simple tic-tac-toe with an A.I. in Lisp as a project for my programming language class. Since I'm a noob with functional stuff, I just abuse progn make life easy for myself. I just hope my professor doesn't mind that too much >.<


This kind of project can be done in no more than 2 weeks while at university. I had a similar assignment in my final year, which didn't include AI, but even if you give it 3 weeks, it's still too short for a project. I also wasn't very familiar with Objective-C (assignment's programming language) back then.

Edit: Nevermind, previous year students had to do tic-tac-toe. It was 'Four in a line' for my class. Or, 'Connect Four' for some people: http://en.wikipedia.org/wiki/Connect_Four
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
April 14 2015 19:05 GMT
#12237
Thank you everybody for taking the time to help me<3

@Acrofales
thanks for testing

@Manit0u
$system->getRoomList()->getRoom(1) it shouldn't return a new array everything time, since it has to keep an index of all the chatroom objects.

1. thanks didn't see that

2. What attribute are you talking about? are you sure its in chatroom since I make it an array in the constructor. or is that wrong?

3. Well thats really silly now you mention it. thanks

5. Considering there should be quite a few ajax calls invoking the script when in reality only 1 script can do something at a time I would have it die on puprose, Hope its ok in this case.

6. I didn't know that, ill look into that more.
The harder it becomes, the more you should focus on the basics.
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
Last Edited: 2015-04-14 19:44:32
April 14 2015 19:37 GMT
#12238
On April 15 2015 04:05 sabas123 wrote:
Thank you everybody for taking the time to help me<3

@Acrofales
thanks for testing

@Manit0u
$system->getRoomList()->getRoom(1) it shouldn't return a new array everything time, since it has to keep an index of all the chatroom objects.

1. thanks didn't see that

2. What attribute are you talking about? are you sure its in chatroom since I make it an array in the constructor. or is that wrong?

3. Well thats really silly now you mention it. thanks

5. Considering there should be quite a few ajax calls invoking the script when in reality only 1 script can do something at a time I would have it die on puprose, Hope its ok in this case.

6. I didn't know that, ill look into that more.


Ad. 2:
array_search( $client, $this->clientList ,true);
You're doing an array_search on $this->clientList, which isn't being set in the constructor. Not only that, you also assume it's an array you can traverse and search through. In theory you guard against it with weak comparison to null, but it's still pretty ugly (passing a null value instead of array to array_search produces a warning).

Ad. 5:
If you're accessing this method via an ajax call then simply do an early return. Like return new JsonResponse('fail') or something. This way you not only stop the script execution but also get something for the ajax API to lean on and display the error to the user or whatever. You can also simply throw an exception there if you prefer.
Time is precious. Waste it wisely.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
Last Edited: 2015-04-14 19:47:25
April 14 2015 19:40 GMT
#12239
On April 15 2015 04:37 Manit0u wrote:
Show nested quote +
On April 15 2015 04:05 sabas123 wrote:
Thank you everybody for taking the time to help me<3

@Acrofales
thanks for testing

@Manit0u
$system->getRoomList()->getRoom(1) it shouldn't return a new array everything time, since it has to keep an index of all the chatroom objects.

1. thanks didn't see that

2. What attribute are you talking about? are you sure its in chatroom since I make it an array in the constructor. or is that wrong?

3. Well thats really silly now you mention it. thanks

5. Considering there should be quite a few ajax calls invoking the script when in reality only 1 script can do something at a time I would have it die on puprose, Hope its ok in this case.

6. I didn't know that, ill look into that more.


Ad. 5.

If you're accessing this method via an ajax call then simply do an early return. Like return new JsonResponse('fail') or something. This way you not only stop the script execution but also get something for the ajax API to lean on and display the error to the user or whatever. You can also simply throw an exception there if you prefer.

edit nvm

also, I did some testing and it appear that I get a new array each time I call for the room,


$roomlist->getRoom(1);
$first_setter = $roomlist->setClients("some value i will pass");
$first_getter =$roomlist->getClients();

$second_getter = $roomlist->getClients();


output:
$first_getter = Array ( [0] => "somee value i will pass" );
$second_getter = Array ( )
The harder it becomes, the more you should focus on the basics.
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
Last Edited: 2015-04-14 21:26:29
April 14 2015 21:25 GMT
#12240
You're calling $roomlist->getRoom(1) but you're not binding it to any variable, so every time you call $roomlist it creates a new room instance (At least that's what it looks like).

What you need to do is this:


$room = $roomlist->getRoom(1);

$room->setClients('some value');

$test = $room->getClients();
$test2 = $room->getClients();


Tell me if it works.
Time is precious. Waste it wisely.
Prev 1 610 611 612 613 614 1032 Next
Please log in or register to reply.
Live Events Refresh
WardiTV Invitational
11:00
Wardi Spring Cup
Krystianer vs TriGGeR
Cure vs Rogue
WardiTV271
LiquipediaDiscussion
RSL Revival
10:00
Season 5: Group C
SHIN vs ByuNLIVE!
Shameless vs TBD
Tasteless1236
IntoTheiNu 725
Ryung 372
Rex124
LiquipediaDiscussion
CranKy Ducklings
10:00
Sea Duckling Open #145
CranKy Ducklings40
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Tasteless 1236
Ryung 372
Lowko286
Rex 124
StarCraft: Brood War
Britney 48108
Sea 14723
Calm 8341
Horang2 1398
BeSt 478
Mini 419
firebathero 413
EffOrt 398
Zeus 225
Soulkey 218
[ Show more ]
Last 182
PianO 121
HiyA 104
ToSsGirL 100
Mind 99
Pusan 78
ggaemo 76
Sharp 71
Backho 58
Hyun 44
Liquid`Ret 43
Aegong 37
Noble 33
Shinee 32
sorry 22
yabsab 16
hero 16
Sacsri 15
GoRush 12
scan(afreeca) 11
JulyZerg 7
Rock 7
Dota 2
Gorgc998
XcaliburYe473
BananaSlamJamma65
Counter-Strike
fl0m2816
Heroes of the Storm
Khaldor122
MindelVK10
Other Games
gofns9955
singsing2514
B2W.Neo416
DeMusliM286
monkeys_forever155
KnowMe124
Livibee94
Mew2King83
ArmadaUGS41
Organizations
Counter-Strike
PGL27347
Other Games
gamesdonequick1220
StarCraft 2
ComeBackTV 539
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 15 non-featured ]
StarCraft 2
• Adnapsc2 9
• CranKy Ducklings SOOP3
• Dystopia_ 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Nemesis3590
• Jankos1153
Upcoming Events
SC Evo League
50m
uThermal 2v2 Circuit
2h 50m
BSL
6h 50m
Artosis vs TerrOr
spx vs StRyKeR
Replay Cast
11h 50m
Sparkling Tuna Cup
21h 50m
RSL Revival
21h 50m
Cure vs Zoun
Clem vs Lambo
WardiTV Invitational
22h 50m
BSL
1d 6h
Dewalt vs DragOn
Aether vs Jimin
GSL
1d 19h
Afreeca Starleague
1d 21h
Soma vs Leta
[ Show More ]
Wardi Open
1d 23h
Monday Night Weeklies
2 days
OSC
2 days
CranKy Ducklings
2 days
Afreeca Starleague
2 days
Light vs Flash
Replay Cast
3 days
Replay Cast
4 days
The PondCast
4 days
Replay Cast
5 days
RSL Revival
5 days
Korean StarCraft League
6 days
RSL Revival
6 days
Liquipedia Results

Completed

Escore Tournament S2: W6
WardiTV TLMC #16
Nations Cup 2026

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
Acropolis #4
KK 2v2 League Season 1
SCTL 2026 Spring
RSL Revival: Season 5
2026 GSL S1
PGL Astana 2026
BLAST Rivals Spring 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2

Upcoming

BSL 22 Non-Korean Championship
YSL S3
Escore Tournament S2: W7
Escore Tournament S2: W8
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
BLAST Bounty Summer 2026: Closed Qualifier
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.