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.

learn more… | top users | synonyms

2
votes
2answers
61 views

Simple class, solely for setting “globals”

I'm aiming for the best and simplest way to access "global" variables set in the config file for my website. So I can use them anywhere, even inside functions It's for file versioning, and I use ...
3
votes
3answers
128 views

Complex if statements in authentication method

I had asked questions about my entire class which I'll flag for closing soon. It appeared to be a little too broad for 1 post so I chopped it up and will be asking a little more specific questions ...
3
votes
2answers
41 views

Pagination filtering

I want to check if there is page variable (in URL) and if it is, if it's correct - it cannot be number 1 because this is default page and it should be valid int ...
0
votes
2answers
87 views

Validating basic data objects

I'm playing around with trying to do things in a better way, and in a class I have for sending emails, I have the concept of a recipient. This gets passed into my other classes essentially as a struct ...
4
votes
1answer
90 views

Extendable PDO Wrapper Class

I've created a PDO wrapper. I understand PDO could be used on it's own, and I'm reinventing the wheel as there are solutions like Laravel's Eloquent that would do a better job. I'd like advice on ...
1
vote
3answers
73 views

Dependency injection/dependency injection containers in MVC web app

I just learned about dependency injection/dependency injection containers, so this is my test using DI/DIC in my MVC app. Controller ...
12
votes
1answer
153 views

Cryptographically-secure super-secret government message transaction machine

-Hello Agent. Are you on a secure line? -Yes, secured. -Good, in 30 seconds the launch codes will be in your e-mail's inbox. You now have the go. Are you ready for the package? ...
2
votes
2answers
76 views

PHP Trait Singleton

An implementation of the singleton pattern in PHP using a trait (added in 5.4). Is there anything missing, any ways to create a second copy of the class? ...
2
votes
0answers
31 views

Application Class Security

Is my Application.php class secure for continuing development? The Application.php acts as a registry for the whole application. I tried not to rewrite already working code that is being pulled from ...
4
votes
2answers
96 views

Optimizing cron job for sending reminders

The following script is being run with a cron. It runs once a minute to see if there is a reminder that needs to be sent. Should I make this run once every 30 minutes? The choices to send a reminder ...
7
votes
2answers
135 views

PHP isset over use? Good or bad?

First, I'm in no way an experienced PHP coder. This is my 5th time working with PHP, so if you see anything that can bee improve, please point them out for me. I have the code checking for the ...
5
votes
1answer
45 views

Secure Functions in a Database Class

I am trying to solve as many issues as possible with my Database Class and bind statements as far as possible without actually doing it in the front-end. The goal is to do all of the heaving lifting ...
7
votes
2answers
106 views

How is my injection protection?

What do I need to do to prevent injections? In addition, if I have any statement/parameter errors, please tell me. ...
3
votes
1answer
64 views

advantage of using __call method

I have wrote simple class that allowing database selection and inserts.Could you please tell me does this a right way to use __call method with any useful advantage of it ? ...
2
votes
1answer
81 views

Optimized solution for a rolling dice code puzzle

I was asked to provide the solution of this rolling dice problem in an interview. When I showed him my solution, he said that there is another way to find the solution. I am looking for answer in PHP ...
3
votes
3answers
86 views

Inline PHP IP access log

For a website, I've got some inline PHP, posted below. It's supposed to log traffic to the website, and it does its job fine. But at the end of the day, I'm not even close to a PHP developer, and ...
5
votes
0answers
74 views

Filtering queries based on the current user state

I have a Symfony2 project. I have an Entity Asset which can have relations with Category. I store a ...
1
vote
1answer
55 views

Class that handles header and footer includes looks like a mess

I tried making a class that handles my header and footer of my site. It looks like a mess, because I like to preserve the indentations as is. But I'm wondering if there maybe is an even cleaner or ...
6
votes
2answers
152 views

My database class extends MySQLi

The following is a small class I extended MySQLi with. I'm going to use this in my upcoming projects, but my main reason to do this class is learning, so I would like to submit this for your review, ...
1
vote
1answer
102 views

Codeigniter ActiveRecord Wrapper Model

Can someone help me refactor this to be more optimized? Performance seems to be very optimal, but I think more can be squeezed from it. ...
1
vote
1answer
53 views

Optimising and consolidating multiple PHPMailer functions

So the two functions below both send emails via PHPMailer but both hold different messages (which use different data from the db). I was just wondering (as I plan to use PHPMailer more) a way to ...
1
vote
0answers
78 views

Data lookup table with Redis and API call

This class' function is to change a given array's data into an ID. The list is set by a configuration file. I have DI the outer array and objects into the class so that if there are any dependencies - ...
3
votes
3answers
662 views

Any simpler and more efficient way of writing this code?

I've noticed I've got quite a few repeated lines in my code. ...
3
votes
1answer
59 views

Return current URL

I was unable to find how to get current URL so here's what I've made. Brief tests didn't reveal anything bad. Your thoughts, educated opinions, suggestions, and comment on potential bugs or ...
6
votes
2answers
280 views

Some tips on a CodeIgniter Model I am building

Can I get some pointers/critique/comments on the following model? (p.s. performance seems great... tested all methods up to 10,000 records) ...
8
votes
1answer
263 views

PDO sign up function inserting data into multiple tables

This is a sign up function called on form submission. It firstly inserts key user data into the users table. If successful, secondary data is then inputted into ...
1
vote
0answers
53 views

Split large import task into smaller subtasks

I have a large import task that runs as a cronjob and I want to split that task in smaller subtasks. Each subtask should be handled by an own class. At the cronjob entry point I prepare the ...
10
votes
3answers
355 views

Listener/Observer Model in PHP

I've taken a look at the SPL Listener/Observer model but found that it doesn't work when using static methods. So I wrote my own but it's very simply. Can anyone suggest ways to make it more like the ...
2
votes
0answers
54 views

Modular dynamic based routing with wildcards

I've created this router for my framework and wanted to get some feedback on if it's the most efficient way to search the routes. The main router ...
2
votes
1answer
102 views

“Property Container” design-pattern

I've tried to write my Property Container design-pattern implementation. Could anybody, please, tell me, if this code is really what I intended to write (follows ...
4
votes
1answer
106 views

Arithmetic quiz using PHP5 and mySQLi

I would very much appreciate a general review of my PHP code which grabs information from a mySQL database and also inserts some information into the database. Overview : Users go to /main.php and ...
2
votes
2answers
67 views

Is there a better way to combine these arrays?

Is there a better way to do this kind of array combination with a PHP native function like array_combine? I'm trying to improve my skills, and at certain points I ...
2
votes
1answer
60 views

How to deal with some of the dependencies?

I am very beginning in PHP and Design Patterns. I have been studying the beautiful book "Head first: Design pattern" and I have been working in some of the codes originally presented in Java in order ...
4
votes
2answers
72 views

Parsing record-jar format in PHP 5.3

Here is a simple function I wrote to parse record-jar data. I need it in a php5.3 application to validate bcp47 language tags. It converts the language subtag registry among other things, into a ...
11
votes
2answers
2k views

Multi-language website management

I have just started to use PHP OOP and I would like to write a class to make a multi-language website. I started from this but I wanted to use OOP so I came up with this: Language.php ...
0
votes
1answer
254 views

Review of my PHP Wrapper around Third Party Soap API

I have written a wrapper for Soap based 3rd party web service. https://gist.github.com/veganista/bd940750d9e240e63b89 I'm pretty happy with it so far (I think, anyway). It's only a small sub-set of ...
2
votes
1answer
55 views

How to optimize the code in order to reduce the loading time of page?

I'm using PHP, MySQL, Smarty, jQuery, etc. for my website. I'm using a MVC architecture to develop the website. Now in one of the functionality I'm fetching a large amount of data and perform some ...
1
vote
2answers
209 views

Simple PHP Autoloader alternative

Though I have heard about the magic method __autload, I still prefer to use this code: ...
3
votes
1answer
1k views

Building a histogram array in PHP

I'm visualizing my stored data in an histogram similar to this one: However, I'm sure that my code smells a lot! So I'd like to have your opinion on how to make it better. ...
2
votes
1answer
122 views

How to optimize the following code in order to decrease the execution time?

I'm dealing with huge amount of data. I've written following code into a function to find out similar questions. It's working perfectly but it is taking too much time in execution. Can anyone help me ...
3
votes
1answer
76 views

Get Ancestor Class Name that Defines CONST in PHP? [closed]

I have a class hierarchy in PHP and in some of the parent classes I have defined a constant, let's assume that constant is called TYPE for my example. I want to ...
1
vote
2answers
184 views

How can I optimize my login script?

I've created an Ajax login for my website but I feel like I can optimize it, but I'm not sure how and where. Questions: How can I optimize my code? Is the code secure? Any ways to break it ...
4
votes
0answers
254 views

Am I using PHP Mcrypt the right way?

I have written a small wrapper class for using PHP Mcrypt for encrypting and decrypting text data. This class generates a salt for hashing the key and encrypts the given data with the generated key ...
1
vote
0answers
158 views

Combine and minimize all .js files in parent folder

I'd appreciate some feedback on my latest PHP script. It is supposed to work like this: When obtained, it checks whether the cache is still up-to-date IF YES, return the cache; IF NOT, reset the ...
2
votes
1answer
212 views

How to put XML results in the MVC pattern?

I have been writing PHP programs in the MVC pattern for quite some time. But I am not sure if I am doing it right. For instance, I have this PHP file that prints a result in XML, and I put this file ...
3
votes
1answer
579 views

Cookie Management Class

I wrote this class to make cookie management easier. I know it makes use of serialize(), but I have no intention of storing very much data in the cookie, and it ...
0
votes
2answers
104 views

Is this an efficient way of organize an array?

The array is dynamic, can be with 7 or more keys, except the first key never changes. ...
2
votes
1answer
200 views

Trying out my first User Registration script

I am trying to write my first script that checks users against a database (MySQL right now) and if they aren't in the database, registers them. I've tried my best to sanitize and validate the form ...
1
vote
1answer
366 views

Retrieving all directorie names (relative path)

Just a small code review. Is there a better way to get all folder names? ...
4
votes
2answers
211 views

Initializing a variable with a function reference (PHP)

I'm working on an old PHP website, and NetBeans is complaining about an uninitialized variable. I'm seeing some code like this: ...