PHP is a widely-used, general-purpose scripting language that is especially suited for web development.

learn more… | top users | synonyms

2
votes
1answer
16 views

HTML Compressor with regex

I would like to compress a Magento HTML page using some regex, and this is what I have written: ...
-5
votes
0answers
27 views

Brands won't appear on the create product form [on hold]

I got an Undefined variable: brands (View: C:\xampp\htdocs\beautyvital1\app\views\products\index.blade.php) on my ProductsController i have the following codes: class ProductsController extends ...
8
votes
2answers
45 views

Trait accessing variables of classes using it

I just tried PHP Traits for the first time, to keep my code DRY : ...
0
votes
1answer
45 views

PHP login redirect security? [on hold]

I wish to redirect users to the login page if they attempt to visit a page which requires them to be logged in. After logging in, however, I want to redirect the user back to their original ...
0
votes
3answers
47 views

Looping to update article codes on one server based on queries on another server

I've read somewhere on Stack Overflow that doing queries in a loop is very inefficient. It will hammer your SQL server and make your script very slow. Sample code: ...
3
votes
1answer
52 views

Inserting data into database

I started learning PHP and MySQL, was using MySQL_ functions. Then I learned they are deprecated, had to choose between PDO and MySQL. I chose MySQL and started using it. As I learn OOP PHP, I ...
-2
votes
1answer
62 views

Display multiple subtype objects in one page

I have a base class with 3 sub ones: Item <-- Book, MusicCD, Software They have some common and different properties but in the view I want to get a mixed list of them and show in one table: ...
4
votes
1answer
31 views

Fetching objects and adding a calculated field in Doctrine 2

I'm making a section that shows a list of blogs and how many comments it has without loading any comment data. My Blog entity is as follows: ...
6
votes
3answers
109 views

Generate every unique combination using all elements from array

I am trying to make a script that generates every possible combination from an array of elements. I have found a script that does it, but it is too intensive and takes extremely long to generate ...
2
votes
1answer
55 views

Validating input against rules

I have created a method that validates inputs based on a set of rules. If an error is found, it is put into an array which can later on be used to display the errors to the user. Below is my code: ...
1
vote
1answer
50 views

Http Request/Response class

I would like to get a feedback on this. It is just a simple Response/Request classes. I tried to keep it simple, so I made two interfaces, and two classes. ...
2
votes
2answers
48 views

Using a registry with static container

I am currently working on a class to make objects and vars available to child classes while attempting to avoid a singleton. Each child with dependencies extend this class and pass params (var names) ...
5
votes
2answers
62 views

Retrieving input from either GET/POST

Today, I created an input class with a method to check whether or not input via GET/POST exists, and another method to retrieve input from either GET/POST, without having to check both individually. ...
0
votes
1answer
82 views

User Registration

I'm fairly new to PHP and am very interested in learning best practices, etc. I have just created a user registration system mostly in OOP that will dump user info into a database I've created. This ...
5
votes
2answers
117 views

Balance braces method

This is a continuation of this question, at least the first part of that question. I want to check if everything in the new code is right or if there are other way to make it better. Exercise The ...
1
vote
0answers
37 views

OOP QueryHandler in PHP

I have a simple database connection class which is using PDO: ...
3
votes
0answers
47 views

Making PHP composable and look functional

I've found myself on numerous occasions needing to with large text-files, where joining this on that, and filtering this out on arbitrary conditions. The first couple of times, this turned into a ...
2
votes
1answer
32 views

Local image cache for external images

I have written a simple image cache script, the purpose is to load the image locally, so i can control the cache times of the images, and i have better load times than the host server, (battle.net ...
0
votes
1answer
32 views

Optimizing execution time of merging images

I am using the below code to merge two images, but it take avg of 6-7 sec for creating 16 images. Is there any way I can speed up my process? ...
2
votes
3answers
61 views

A class which represents an SQL table

I'm representing DB tables as classes (in this case PHP classes). This has the goal of modeling every section of the web page, where you will get inputs from the user. My actual base design is: One ...
-1
votes
1answer
45 views

PHP/MySQL: Best way to check if images are identical? [closed]

I got a table where i add user personalia. Additionally I have one picture stored in the filesystem for each record, named after the id of the record like below. personalia table: ...
0
votes
2answers
57 views

Insert into table class

This class should function as a simple insert into table. What do you think about it? How can I make my code better? ...
1
vote
2answers
78 views

PDO class extend

I am moving in to OOP PHP and having some problems extending my database class to my objects. I am still new to the variable scoping in OOP PHP, so if it a tiny syntax error I apologize. If my ...
2
votes
0answers
18 views

Refreshing / Cycling through a parsed RSS feed every 5 mins

I am working on a monitor signage display and have a "welcome to RSS" feed with just a title and desc. I have code from feedEk that's been tweaked a bit to parse the feed and cycle it so I only have ...
3
votes
2answers
70 views

PHP OOP calculator form

I aim to improve my PHP OOP skills and made a simple calculator. Visitors can choose 2 numbers and a prefix, so they can add, subtract, divide and so forth. The output is the sum. The good thing is ...
1
vote
0answers
51 views

Making a CRUD function reusable

I uses slim router and made a folder model controller view, below is one of my model files; I made one database with one model. I have some problem in my project: there are several databases like ...
3
votes
1answer
36 views

LinkedIn work history time

The code I have works. Was just curious if there was an easier way to write the function. Here is what I have. Note: It is referenced inside of an Object so you may need to change the ...
1
vote
0answers
43 views

Singleton request validator and sanitizor class

I have tried to code a PHP singleton class for validating multiple/single fields (sanitizing is optional). When validating single field, on success it will return 1 (...
2
votes
2answers
80 views

Small PHP DAO app

I'm creating a small app and decided to write my own DAO for learning, etc. At the moment it's in one big file, which I really don't like. Could you give me some tips on how: you would separate ...
2
votes
0answers
45 views

Immediately send redirect response, preserving session data

This question is for Laravel 4 only, as the relevant parts are completely refactored in the upcoming Laravel 5. I have written an helper function for validation, so I only have to put this in ...
2
votes
1answer
37 views

Simplify double AJAX request for jQueryUI's autocomplete widget

I'm using jQueryUI's Autocomplete widget for a product search. The data is in a database, so as the souce I passed it an AJAX request. My problem is, that I need some data about the currently focused ...
2
votes
0answers
22 views

Upload multiple files in different formats and sizes from one HTML form

I have a html form with some text input fields and three file upload fields. two of them should be images and one should be a file (pdf). My code is working well but I feel this is not the proper OO ...
1
vote
0answers
33 views

PHP DOM XML Creation

I am currently working on Shopify webhooks which posts XML to the Colorado timber line API. But due to the order protocol of the Colorado timber line API, it is required to modify the XML posted by ...
2
votes
1answer
49 views

Hanging semicolons in multiline statements

I'm writing code to do line printing to a template -- counting characters to box A, then to box B, etc. -- and as such, it's not very modular. There are a lot of (long) variable names and each ...
2
votes
0answers
27 views

Is my controller for editing information about videos doing too much?

My project uses Zend Framework 2. I'm trying to determine if I am doing too much in my controller as a rule for my development. I have built my controllers like this for a while and haven't run into ...
3
votes
0answers
41 views

Security of login and register system

I need some help with my register/login functions. I'm not sure if I understood bcrypt correctly either. Is this good or do I have to do any changes? Did I miss ...
3
votes
0answers
53 views

“Table Data Gateway” pattern

Using the table data gateway (TDG) pattern, I created a class QuestionGateway for retrieving, adding, updating, deleting, and sorting multiple-choice questions. ...
1
vote
1answer
58 views

Breaking up a PHP class between a master class and subclasses

I have a huge class taking care of companies informations in my app. Arrived at 4000 lines of code (!), I finally decided to break it up. However I am not too sure if the way I am doing this is the ...
0
votes
2answers
52 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, ...
0
votes
0answers
3 views

Joomla! 2.5 backend component adapted to Joomla! 3.3: Toolbar has stopped working [migrated]

While adapting a Joomla!2.5 backend-only component to Joomla!3.3, I've ran into the issue of the toolbar in the data edition page not working at all. Only two buttons were declared: Save and Cancel; ...
3
votes
1answer
43 views

JOIN and sprintf rather than two queries and echo

It works fine, however it's a little messy. I understand it would be better for performance to use JOIN and have been advised before to use sprintf. However, it's ...
4
votes
1answer
43 views

Simple One Way IPC Implementation for pcntl_fork

It is a common task for me to need to run many nearly identical child processes. Not often but sometimes I need those child processes to communicate their results back to the parent process. I have ...
5
votes
2answers
54 views

PHP Usersystem basic class

I've recently picked up OOP in Java and I'm trying to use it for my PHP usersystem. I've come up with the following generic.class. On my main site, I'll simply put a ...
2
votes
1answer
42 views

PHP application configuration

I've started looking at Heroku for application hosting and deployment and it appears that my configuration constants need to be stored in environment variables. I can do this in Heroku, but my ...
3
votes
2answers
104 views

PHP secure random number generator

I just wrote this function and I was curious if anyone could find any flaws in it? It look pretty secure to me but I just want to make sure since I'm no cryptography expert. ...
2
votes
2answers
51 views

Is this system of text protection reliable?

I've got a text I don't want to be copied by users. To avoid that, I'm using this code: index.php ...
0
votes
1answer
39 views

Implementation of a URL router

I was wondering if you could provide some feedback on this Router class I built. Worth noting that it relies on an Apache rewrite rule that always redirects to this file, but passes the path into ...
0
votes
1answer
53 views
2
votes
2answers
83 views

Combining two arrays using nested foreach loops

I have the following arrays: ...
5
votes
1answer
83 views

Active directory password changer

I have written this Active Directory password changer script. Comments and testing is appreciated for things I may have overlooked, since this is my first AD Script. There are two parts: PHP and ...