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

learn more… | top users | synonyms

-3
votes
0answers
9 views

Can't Solve This in Any way.Here all codes I seeing correct but I can't success in login procedure in this way by doing salt. anyone show me the fault

This is my function page. Where I have included all the function for login and hashing/salting. <?php function redirect_to($new_location){ header("location: " . $new_location); exit; } ...
2
votes
2answers
5 views

How can I keep data integrity across multiple services in a transaction-like fashion with PHP?

I find the concept of transactions really useful when working with databases because obviously it allows you to rollback changes if one step of a modification goes awry. Is there some way I can ...
0
votes
1answer
58 views

What is the problem will happen if I create auto generate ID without using mysql auto increase of mysql table by my self?

I would like to ask you a question about MySQL AUTO_INCREMENT. I already created my own function to generate AUTO_INCREMENT when the user inserts any data input a table in MySQL. This function works ...
0
votes
0answers
38 views

I am trying to implementing a stream/notification feed, but I have a dilemma

For many months now, have I tried to figure out how to implement a stream/notification feed? It can be implemented by having three tables in the database (e.g. activities, user, and user_activities) ...
-2
votes
0answers
26 views

Best approach to subscription billing [on hold]

I am creating a subscription based site from scratch. And i want to know what would be the best approach or best way to be able to accomplish subscription billing every month. So lets say a user ...
3
votes
2answers
399 views

How to use SOLID principles in this example

I have reading about SOLID principles last week and decided to try to solve real world problem by using them. So I got the problem of real world ecommerce site managing totals. Problem Statement: ...
4
votes
1answer
71 views

Clean Architecture - How to go from “Database Driven” to “Independent of Database” [on hold]

I am looking for some clarity and hopefully some advice on writing clean architecture for a large system. My Companies "Web Solution" is +-10 years old, my job is to rewrite it. It is written across a ...
-2
votes
0answers
24 views

PHP Half-Hour Timezones Missings? [migrated]

In PHP I am using DateTimeZone::listIdentifiers() to get a list of timezones for user selection. This seems to be working fine, but missing from this list are the half hour timezones. Notably: ...
1
vote
1answer
64 views

Is it a good idea to modify the array keys in foreach

First let me say that i am talking about PHP, but the question is a general one. Some times i need to modify an array key for example something like: $temp = array(); foreach($arrayIWantToModify as ...
-1
votes
0answers
57 views

How to do simple video processing with PHP? [on hold]

I've been working with PHP for a while now, but this is the first project I've done that requires video processing. Ultimately, we want to do the following: Resize videos down so that their ...
-3
votes
0answers
32 views

Querying large number of timestamps [on hold]

I have a list of timestamps in a table (there can be millions) of every time an auto-save event occurs. I want to track the amount of time people spend on a page, so every time they type a word, I ...
3
votes
1answer
69 views

Designing a ticketing system where the User and Administrator have similar but different functionality

I am designing a simple ticketing system in Laravel 4. The system will simply allow a User to create a ticket, and an Administrator to answer it. The User will be able to: View a list of his ...
1
vote
2answers
269 views

Cleanly using PHP Iterator class in Loops - calling first element

I have implemented the Iterator class in PHP and built the follow mandatory methods as follows class I implements Iterator { private $a = []; function __construct(array $a) { ...
2
votes
1answer
188 views

Single complex or multiple simple autoload functions

Using the spl_autoload_register(), should I use a single autoload function that contains all the logic to determine where the include files are or should I break each include grouping into it's own ...
-3
votes
0answers
39 views

die() or try/catch when interacting with MySql database in PHP? [closed]

A lot of tutorials and books I have been over and read have used the die() method to catch an exception when interacting with a local MySQL database For example: mysql_connect($dbhost, $dbuser, ...
12
votes
4answers
2k views

Why exactly can't PHP have full unicode support?

Everybody knows, that PHP has problems with Unicode. Version 6 is effectively abandoned, because of Unicode implementation difficulties. But I wonder if anyone knows what are the exact reasons? ...
33
votes
7answers
4k views

Is there a need to keep tests for simple (self-contained) functions?

Consider this: public function polynominal($a, $b, $c, $d) { return $a * pow($x, 3) + $b * pow($x, 2) + $c * $x + $d; } Suppose you write various tests for the above function and prove to ...
2
votes
1answer
363 views

Change routing to comply with Law of Demeter

I have a Task, Owner and Plan. Charge values are kept in a plan, owner is on a particular plan and task knows its owner. A task needs to setup its charges based on the knowledge the owner has. Owner ...
11
votes
2answers
611 views

DRY principle in good practices?

I am trying to follow the DRY principle in my programming as hard as I can. Recently I have been learning design patterns in OOP and I have ended up repeating myself quite a bunch. I have created a ...
1
vote
1answer
218 views

Laravel relationships and database schema

I am playing around with Laravel and came across something in the documentation for defining 1 to 1 relationships between tables that I would like to get feedback on. The example in the docs is ...
-5
votes
0answers
30 views

Constantly getting PHP error when I submit a form [closed]

I am constantly getting a PHP error which is You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Change) VALUES ...
-5
votes
0answers
28 views

PHP - Condition and Loop [closed]

i am writing a PHP script and i want to check if a number is between two other numbers like 20< x < 40 but in a very higher Range like this : ...
0
votes
1answer
39 views

How to delete active sessions and enable different users to log out from the system without any clashes [on hold]

Currently been working on some few small scale web applications but still did not understand the logic behind on how to clear off a target session? For example, imagine a small web application that ...
1
vote
1answer
642 views

MVC URL structure with URI parameters

When creating routes for your MVC web application I have seen two possible ways to pass variables to a controller method: With the first approach the variable is passed to a parameter of the ...
2
votes
1answer
123 views

Recommend an approach to decouple Product and Access code constructs, in order to simplify Product testing

I have some code that tightly couples Product specific code and Product-Access code. I am not sure how to untangle it. So for example, for testing Product, I have to mock up Access objects. And ...
4
votes
1answer
52 views

Should domain model be intelligent or there must be services, which operate it?

I'm building a web-app for a licensing service. My domain models are Licenses, and they can be of two types at the moment: server and client license. They are almost same, except server license has ...
4
votes
1answer
281 views

Is this a good implementation of the builder pattern? [on hold]

I'm trying to design an SQL builder in PHP. I'm trying to make it so that the system could work with different database systems (e.g. Oracle, MySQL, MSSQL). Here's what I've got so far. First, I have ...
-2
votes
0answers
14 views

Help with Shell [migrated]

I was trying to create my own shell. So I have this code: <head> <title>Command Shell</title> <link rel="stylesheet" href="console.css"> </head> <body> ...
7
votes
2answers
161 views

Cross-language Test-Driven Development

The short question: How do you follow Test-Driven Development on a project that spans multiple languages? Specifically, I'm writing a web application that uses JavaScript and PHP, and I want to ...
5
votes
2answers
167 views

Persisting Large/Complex Entities with the Command Pattern — Am I doing it right?

I am in the process of designing and building a large-scale inventory management software-as-a-service that will, hopefully, live a long and fruitful life. Therefore I am exerting a lot of effort ...
0
votes
0answers
58 views

Execute a method upon loading a class [migrated]

I need to have a static constructor. I was always wondering why there is no support for this functionality. I need to run a function once when the class is loaded, currently the way I've seen it done ...
1
vote
2answers
170 views

Purpose of encrypted product ID/key in shopping carts

I'm a newbie for PHP ecommerce applications. For my academic activities, I need to complete a shopping cart system with basic shopping cart functions. I have studied several apps which are already ...
2
votes
2answers
169 views

matching usernames with their password

We are working on a simple login/registration form. Our login script checks to see if the username and password exist in the same row of the database. If it does exist, we bring the user to a welcome ...
2
votes
1answer
60 views

For DI, where to create dependencies (new objects) specifically within framework code?

Basic requirement I'm making a framework for learning purposes (and likely usage on personal sites). I'm using dependency injection in classes and I'm trying to design where would be a good place ...
2
votes
2answers
498 views

MVC with Post/Redirect/Get

I have a question in mind for the MVC pattern for a long time now. When using the Post/Redirect/Get principle then it doesn't make sense to use ONE model in the sense of MVC, right? Why should I ...
1
vote
2answers
59 views

Many AJAX requests to check domain availabilities [closed]

I've recently developed a website that randomly generates unique names, then checks for their .com availability. In order to do this, I call 3 AJAX requests to a php page where it randomly generates ...
1
vote
1answer
180 views

DI container with multiple instances of same object

I'm looking for idea to make a DI container that can store multiple instances of the same object. Usually, a DI container should store either a single instance of the object, or create new object each ...
0
votes
1answer
2k views

Reporting Solution in PHP / CodeIgniter - Server side logic vs client side

I'm building a report for an end user. They would like to see a list of all widgets... but then also like to see widgets with missing attributes, like missing names, or missing size. So i was ...
1
vote
0answers
121 views

How safe is returning a password from a function? [duplicate]

Is returning sensitive data like a password from a function safe, and what attack vectors exist? (Personally, it is regarding PHP, but is a general question.) function returnDBPass(){ ...
3
votes
2answers
235 views

Scheme/Design Pattern for allowing a certain outside class to set properties

I came up with a solution (in PHP) to a problem and am wondering if it is a named Design Pattern, and if it is good practice. I have a collection class and an item class. The collection class is the ...
1
vote
2answers
107 views

Relationship between objects

I got the models Post and Category. A Post is assigned to a Category. A Category has many Posts. They should be stored in a database. I implemented the following classes for it: Models/Post.php: ...
0
votes
0answers
52 views

Best practice: Web service to issue sequence numbers

We have several disparate systems. These systems assign ORDER numbers. Basically, these are sequential numbers. They are NOT database ID numbers. These order numbers are like "A01457" or "Z4T456", ...
0
votes
0answers
27 views

Authenticate Joomla User from an External App based on Node.js, Javascript and mongoDB

I have an iOS App which currently pulls in all the data from the MongoDB using a Node JS server. Currently my API / my node server handles all the data manipulation the iOS app/Swift only displays the ...
0
votes
0answers
69 views

Using a PHP loop or MySQL table for arrays values

I have the following results page from the previous form: <?php //Get the form results (which has been converted to an associative array) from the $_POST super global $musicgenres = ...
1
vote
1answer
328 views

Design pattern where decorated object may ask for things like “status updates” from the decorator to perform it's role?

Here's an situation that has haunted one of my open-source projects for quite some time. Imagine if you could represent every front-end input form with a single backend object? An object that ...
0
votes
1answer
267 views

Should I use session or cache to keep the time it last polled when polling to server at intervals?

I'm building a web chat app using session to keep the time the app last polled so that the server can determine whether messages exist between the current polling time and last polling time. It works ...
1
vote
1answer
61 views

Should I use autoloaders in modules?

Lets say I'm running a PHP app like Magento, PrestaShop. Now these system have their own complex autoloaders to load controllers based on routes, required classes, models, etc. Most of the time as a ...
0
votes
3answers
405 views

How do I handle 3rd party search result data (via cache)

I have a search function on my site and it is taking data from 6 different 3rd party resources. The problem is, it takes too long requesting the data over and over again on the results page. I've ...
-1
votes
1answer
94 views

How do front-end developers test pages when the files they are handed are PHP views? [closed]

Someone who has a PHP project invited me to do the front-end work on his site. I don't know PHP, I've only ever worked with HTML/CSS/JS files. I cloned the project files from GitHub, and all of the ...
0
votes
0answers
32 views

MySQL schema migration table and field mapping

I have inherited a project with the following set of components: REST API, public web application and internal admin web application and MySQL dB. I am commissioned to develop updated version of the ...