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

0
votes
1answer
24 views

Form submit using POST handled in PHP

I have this code working for submitting a form using PHP and HTML (Bootstrap). I did not post the CSS, so I hope this is not an issue. I am interested if this code is clean, following good practices, ...
-1
votes
0answers
15 views

PHP or Jquery code to parse a string [closed]

i need to parse following string using php or jquery. ...
0
votes
1answer
48 views

Product page filter

I am still learning Laravel and I am in the process of creating a small shopping website. On the left hand side there are a series of filters that appear depending on what products have come back ...
0
votes
0answers
24 views

PHP Dependency Injection - magic methods injections?

I'm trying to get my head around DI. Am I doing it correctly for classes that follow DI pattern? ...
1
vote
0answers
46 views

Parsing multipart/form-data in php for PUT requests

I have recently found that I needed to be able to parse multipart/form-data for PUT requests made to my REST API. This allows batch photo uploads, which has been a requested feature. As we all know, ...
0
votes
1answer
43 views

Image manipulation PHP class using PHP's Image Functions

I am working on an image manipulation class for a project to re-size uploaded slider images to 780 X 397 and uploaded avatar pictures to 220 X 220. I am wondering if this is a good way to construct ...
3
votes
1answer
37 views

Checking if my code is secure

I'm deploying a PHP project, and I always try to use prepared statements, but unfortunately, GoDaddy does not have the mod mysqlnd which I use it for the function ...
1
vote
0answers
31 views

Why is entangling injectable with class that uses it a bad practice? [migrated]

I have had this argument for a while, because I have noticed some people prefer "readable" code over properly structured one. So in the example I am showing, basically I have this ...
3
votes
0answers
69 views

Laravel Testing: Is this testing too much of the inner workings?

So I'm using laravel for a project and have a InvoiceRepository and a InvoiceRepositoryTest and I have written the test first ...
2
votes
0answers
53 views

Sorting an array to match the order of values of another array

I'm running hundreds of curl operations in parallel to my own API, the response array that I get is out of order ( the reason being that the first one to finish gets added to the response array ...
8
votes
4answers
200 views

Blog/Forum implementation

I've started learning PHP for university-related projects today. I tried implementing a basic blog/forum. Here's the full source code. It has the following features/design-decisions: There are ...
2
votes
1answer
37 views

Optimizing mcrypt encryption class further

The following is a very simple implementation of an Encryption class using mcrypt whereby the functions encrypt and ...
3
votes
1answer
35 views

Geocoding library

I've written a Geocoding library that is hosted on Github. It has got 7.9 rating by the scrutinizer. I've checked and the only thing that I think I can improve is ...
1
vote
1answer
78 views

Extracting components of a street address

I have got the following function in my class that I think can be further be improved but I'm lacking ideas how: ...
4
votes
0answers
41 views

Zf2 and doctrine model implementation

I've implemented for the first time Doctrine-ORM on my SOAP server application; can you tell me if I could optimize some of the written ORM-related code? More specifically, is it a good practice to ...
5
votes
1answer
71 views

Doing a roll back with multiple MySQLI prepared statement

This is my code for doing a roll back with multiple MySQLI prepared statement. I want to know if anything is wrong with the code. ...
2
votes
3answers
106 views

Finding combinations of 3 numbers

What this code tries to do is find possible combinations of three numbers. For example, let's say I have the following numbers: 1, 2, 3, 4, 5, 6, 7 Some ...
2
votes
2answers
76 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
147 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
59 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
100 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
246 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
88 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
175 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
107 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
34 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
185 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
156 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
52 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
119 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
70 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
92 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
95 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 ...
4
votes
0answers
97 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
63 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
451 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
150 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
60 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
103 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 - ...
2
votes
3answers
676 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
63 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
328 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
594 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
62 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
604 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
58 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
118 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 ...
5
votes
1answer
148 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
71 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
62 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 ...