Dan
  • Member for 5 years, 6 months
  • Last seen more than a week ago
  • England, United Kingdom
Palindrome checking function
8 votes

To start with id remove the code that you written twice by re-arranging the if statement into this if ($wordLength % 2 == 0) { $firstHalf = substr($word, 0, $wordSplitPoint); } else { $...

View answer
Custom MVC framework
Accepted answer
4 votes

Ill just jump right in; Composer To The Rescue So you have attempted autoloading, thats great! But by modern standards you should be using composer to; Manage your dependecies Manage autoloading ...

View answer
Simple basic calculator php class
4 votes

Im not going to comment on the implementation of the calculator (there are more well versed people out there) but I will comment on the coding style; Return early (or in this case throw early) I ...

View answer
php Laravel - given a certain argument, call different function
Accepted answer
3 votes

I don't personally see a problem with the way its currently structured as there aren't that many options, but you could do it a couple of other ways; Option 1 Array function name mapping (hacky name ...

View answer
Should I add the "fetch_group" method to my user class or should I create a separate class for group
Accepted answer
2 votes

Logical inconsistencies You create a User object expecting a user_id to be passed to setup the object, id object to this design but im sure you've got it covered, but then later on you ask for a ...

View answer
Map value to color rgba
Accepted answer
2 votes

Function name The function name getColor isn't representative of what it does its better of being named createRgbaString (or something along those lines) Return early Your script returns in two ...

View answer
Simple AJAX view loading approach
Accepted answer
2 votes

Without really knowing a great deal about how your code is structured and basing it purely on your ajax function you could so somethhing like this; function loadView(url, beforeSend, callback) { ...

View answer
Forum system implementation
Accepted answer
1 votes

How about something like this there is some checking that needs to be done because I inverse the $isPost bool and that could be buggy public function postPersist(LifecycleEventArgs $args) { $...

View answer
PHP OOP registration with User class and singleton Database class
1 votes

For reasons laid out in this stackoverflow question the singleton design pattern is not good match for PHP! Clone Prevention The advice from the accepted answer to the above stackoverflow question ...

View answer
Check bitstamp.net exchange rate, compare it with previous rate
Accepted answer
1 votes

Id make your code more functional (if your not going to use OOP) the fact that this code is slow is probably your internet connection (as mentioned in the comments) First as the api is returning ...

View answer
Users management php class
1 votes

Early Returns I prefer early returns for example if(!$stmt->rowCount()){ echo 'Username or email does not exist in the database.'; return false; } $result = $stmt->fetch(PDO::...

View answer
VBA code slowing workbook
0 votes

This is untested but is this any faster ? Private Sub Worksheet_Change(ByVal Target As Excel.Range) column = Target.Column ThisRow = Target.Row If (column <> 1 Or ThisRow = 1) Then ...

View answer
Simple wrapper for PHP mysqli connection
0 votes

PSR 2 Psr2 is a code standard for php use it, most ides have good integration to auto-reformat your code read about it here Generally Wrapping libraries for databases is a bad idea, how do I start ...

View answer
Simple router in PHP
0 votes

Expanding on the answer provided by unherz; Validate the programmer Sometimes we make mistakes so you should check the $settings provided by the programmer are correct as you require them to pass at ...

View answer
Creating an MVC router
0 votes

Dependency Injection You instantiate all the controllers with new $this->controller what if my controller has dependencies ? Instead of your controllers looking like this; public function ...

View answer