The fifth version of the PHP: Hypertext Preprocessor (PHP) scripting language. It features the Zend Engine 2, better object model support, and many other improvements over PHP 4.
0
votes
2answers
60 views
methods in the class so close in what they do
I have this class that has these two methods that are so closely related to the each other. I do not want to pass the flags so I kept them separate. I was wondering if there is a way to rewrite it so ...
3
votes
3answers
94 views
PHP Simple OOP Class
I am still learning OOP and I need a little help, I don't really know how to properly make this not look so terrible.
Any thoughts?
<?php
class Noti {
public static $app;
public static ...
3
votes
1answer
60 views
code review for this method
This method recieves an array of data and does some stuff in database. Need to get some review on it if possible
public function doSomeStuff($arr = array())
{
$id = ...
4
votes
2answers
118 views
Validation Class - Feedback Welcome!
I have written a Validation and Form class in PHP.
Validation class allow you to define the rules of each field and a error message.
Form class allow you to get a error message and also allow you ...
4
votes
1answer
153 views
Comparing multiple fields from two tables, looking for matches, updating 2nd table
In my never ending quest to improve my coding skills I am requesting peer input on the following code logic. I am asking because I'm -NOT- an expert, but would like to be one day. Source material and ...
3
votes
1answer
124 views
How to improve Try…Catch Block for PDO?
I have written a PDO wrapper and a class file like a model. So far, it's looking so good! I am just confuse where I should put Try...Catch block - Would it be better to place in PDO wrapper ...
5
votes
2answers
96 views
When an object has different representations… what's the OO pattern?
I've an AbstractMessage object (a hierarchy, actually). It represents a small text message and can be sent using different transport methods: HTTP, REST and a "mailer" transport. Each transport relies ...
1
vote
1answer
55 views
How to improve a file access permission/deny function?
I've quickly made a function to deny or allow access to files that are only used thru Ajax Calls.
Key Generator
/**
* Generate a key for file access permission
*
* Function that returns a key to ...
4
votes
2answers
106 views
Would be possible to refactor this PHP code more?
I really don't like the so many return statements. Anyone think that this could be refactored more?
public function validate($value, Constraint $constraint)
{
if('' === $value || null === $value) ...
2
votes
2answers
54 views
Is this function properly structured, leading to a secure row insertion?
I have the following function to insert a new row into a table:
/**
* Insert row into the designated table
*
* Function to add a new row into the designated table
*
* @param str $table ...
2
votes
1answer
58 views
How to optimize function that checks if a directory is empty when having over a million files inside?
I have the following function to confirm if a directory contains files:
/**
* Check if the directory is empty
*
* Function to ascertain if the specified directory contains files.
* Comparing to ...
1
vote
1answer
99 views
PHP Config Class
I'm working on a config class for PHP, where I can easily bring in config options. Any improvements/suggestions are appreciated.
Example usage:
echo Config::get('database.host');
// Returns: ...
8
votes
3answers
986 views
Looking at this code, would you say I'm an OK coder?
Looking at this code, would you say I'm an OK coder?
I just created this during a live screencast. The people who were on there were very very very critical of almost every line of code. They say I ...
0
votes
1answer
105 views
Optimizing blocks-maze generation script php [closed]
I created script that generates maze or some kind of dungeons that looks like this:
http://s13.postimage.org/4uify3jxj/blocks.jpg
I have problem with optimize, because when I've tried to add blockade ...
1
vote
2answers
119 views
Fun with conditionals (i'm bad…)
Yes, i'm bad at conditionals. I don't use it so much and i feel a bit lost with them. How would you (if possible) refactor or change this little piece of code?
Second improved version:
...