Questions about PHP, a widely-used general-purpose scripting language that is especially suited for Web development.
-4
votes
1answer
41 views
HTML AND PHP website [on hold]
I just started learning web programming through an android app made by SoloLearn last week. I crammed in the basics of html and css during that time, now I need to make a grading system where ...
5
votes
6answers
192 views
Should I always store parsed data in database before manipulating?
I am about to start a new project which involves taking an excel file, parsing the data (php-excel-reader) and then using the parsed values in a HTML email.
My question is pretty simple. Is it better ...
0
votes
0answers
19 views
Better way to build SQL query from form input? [migrated]
Very new to php. Using XAMPP, netbeans.
I am using a <form> to send various input parameters as a GET to retrieve data from a very simple two table MySQL db.
After filtering the inputs ...
0
votes
1answer
148 views
Confusion over Node as a “script” vs Node as a “server”
As I was beginning to tool around a bit with node, I was told that I needed to undergo a little bit of a paradigm shift since I was coming from a PHP background. I would ask questions like, "I have my ...
0
votes
1answer
65 views
Strategy for Public / Private API, Encrypted (or Hashed) Data, and Server Compromise
In this very simplistic but realistic scenario, I have 2 combo web/database servers (A) behind a load balancer and a single IP address. They also permit access only from one IP address -- the client ...
-6
votes
0answers
29 views
Multiple image upload into database [on hold]
I got a situation, where i need to select multiple images and insert into database. what could be propre way to achieve it?
thanks in advance.
-1
votes
0answers
42 views
How can I make sum of tree's child node values and put the sum to top node? [on hold]
I am developing an accounting software in php. There is a group wise party ledger that is a tree like the page below.
Parent is group and leaf is particular.
At first I have generated the group tree ...
5
votes
0answers
42 views
Algorithm to generate Edges and Vertexes outwards from origin with max multiplicity of 3
I am creating a 2d game for a website where the universe can grow extremely large (basically infinitely large). Initially, the universe is composed of 6 stars that are an equal distance from the ...
3
votes
2answers
128 views
How are POST/PUT/DELETE data passed to APIs?
I know that the data is passed through HTTP, but I'm not sure if I should be passing data through HTTP headers, or HTTP bodies. Which one is the convention for APIs?
Also, theoretically using PHP, ...
-4
votes
0answers
82 views
MVC both procedural and OOP? [closed]
I am creating a web application using PHP. I am doing my best to implement an MVC structure based on my understanding. I am not using a framework such as Laravel, etc.
Currently I am implementing it ...
3
votes
2answers
128 views
Implementing “buy one get one for free” coupon logic for shopping cart
Trying to solve bogo coupon logic with proper design pattern, but having trouble identifying one.
Use case: "Buy iPad get SmartCase for free"
Suppose we have the following objects:
Product:
- ...
-1
votes
0answers
49 views
Recommendations for storing and accessing information with PHP [on hold]
Suppose that I am developing an online store. The website is built from the ground up with PHP and does not have an admin interface for simplicity reasons.
The PHP code will dynamically generate a ...
2
votes
4answers
184 views
How to properly reverse the if statement when you have two conditions in it?
In PHP I have this if statement ( $first and $second will evaluate to true or false):
if ($first && $second) {
// evereything is OK
} else {
throw new Exception()...
}
My real code ...
0
votes
0answers
24 views
How to call non-static methods statically within the same class (not strict mode) [migrated]
We have a library that uses a lot of static methods. However, this has made testing in PHPUnit difficult as I cannot mock those static method calls. So, I'm in the process of removing the static ...
3
votes
3answers
139 views
Are exceptions only for handling errors?
I have a script that throws exceptions when something goes wrong. However, for the purposes of testing I also want to capture specific points although I'm not sure whether they would be deemed errors ...
-2
votes
0answers
42 views
how to select between two dates but I already used the WHERE so how can I select between two dates [closed]
"SELECT status, DATE(order_date) AS date, SUM(`total`) AS total_sales FROM orders WHERE status = 'Recieved' GROUP BY date";
how to add the between code here when I already used the WHERE
0
votes
1answer
159 views
Is PHP7 a static or dynamic typed language? [closed]
In the past few years, we've been using dynamically typed versions of PHP. However, in PHP7 we have an option to enable 'strict types':
PHP RFC: Return Type Declarations
PHP RFC: Scalar Type ...
-4
votes
0answers
54 views
Latency occurring in the sql query when using IN and EXISTS [closed]
I'm facing a latency issue when loading the sql query.
I'm using IN and EXISTS in my code, maybe this is causing the issue.
Is there any other alternative way to improve the performance by using ...
0
votes
2answers
158 views
How to analyze a code of a web application which is running? [on hold]
Joshua Bloch said in an interview that the best way to know and understand code written by others is to read it, mentally or through a debugger. Well, my question is this: is it possible, through a ...
-2
votes
0answers
10 views
Encrypt password login problem [migrated]
I am using below code to encrypt user registration password during registration. But the Problem is that, i can't get login with same password again, i might be because password in DB is different and ...
0
votes
2answers
73 views
How to simulate method overloading in langs without such feature? [on hold]
Langs like Java knows about true method overloading:
class Overload {
void demo (int a) {
System.out.println ("a: " + a);
}
void demo (int a, int b) {
System.out.println ("a and b: " + a ...
1
vote
0answers
85 views
Can this be used to implement Post Redirect Get pattern?
I am trying to implement proper a Post Redirect Get on a PHP site (question is language agnostic in nature however). I thought about it, and realized that running this code on every request seems to ...
0
votes
1answer
65 views
Why use PHP_AUTH_USER instead of taking credentials under post method
What would be the advantages of using PHP_AUTH_USER and PHP_AUTH_PW instead of the verifying the credentials under method - post .
Why i should use:
$_SERVER["PHP_AUTH_USER"]; and ...
1
vote
1answer
68 views
How can I create a client for a service without hiding the parameters needed for each endpoint?
I'm creating a client to a third-party soap web service in my application. Here is the way I'm thinking of doing it:
Create a ClientFactory that makes a client based on the wsdl file, and sets ...
16
votes
2answers
1k views
Is it a good idea to define one big private function in a class to maintain valid state, that is, to update the object's data members?
Although in the code below a simple single item purchase in an e-commerce site is used, my general question is about updating all data members to keep an object's data in valid state at all times.
I ...
-1
votes
0answers
45 views
How pass request data from controller to service in mvc [duplicate]
I use php and laravel 5 framework for my project and I figure out that logic should not be in controller and I moved them to services.
my question is how should I pass input data (came from html form ...
2
votes
2answers
172 views
Is equating a variable to a function that takes the same variable bad programming?
Is it improper programming to set a variable equal to the result of a function that accepts the same variable? The languages in question here are c#, javascript and PHP (not sure if this works in C ...
3
votes
1answer
64 views
why use authentication token instead of session_id for app(android side) in REST API
in normal php web application after login we use session_id that came from web browser to check if user loged in or not.
But in REST API authentication I read some tutorials that say php should send ...
-4
votes
0answers
54 views
How to Protect Source Code from Unauthorized Use? [duplicate]
I am working on a subscription-based library for websites (PHP, JS, HTML, CSS). There are two ways that it can be implemented:
WE implement it for the client
THE CLIENT is tech-savvy enough (or has ...
2
votes
2answers
81 views
Best approach to develop php mysql project with multiple developers
We are 4 developers working on a PHP-mySQL web project. Currently we work together as described below:
All project files except DB is hosted at GitHub
All project files except DB is hosted at GitHub
...
6
votes
2answers
116 views
Advice for designing API request rate limiter?
I'm in the planning stages of a web application that makes heavy use of data retrieved from a third party's REST API. This data is cached on the server and requested by clients via AJAX. The REST API ...
0
votes
1answer
175 views
PHP framework advice needed [closed]
I started PHP programming around 2002, when there were not that many frameworks around. Over the years, I developed my own PHP framework, which seems to be entirely different from any standard I come ...
-2
votes
2answers
86 views
All methods in one file/class versus multiple files/classes [duplicate]
This question is mainly talking about PHP, but I think it can be applicable to other languages as well. This is a question about code organization.
I have a friend who insists the best approach ...
-1
votes
2answers
116 views
What technique can I use to test my code when code renders out an untestable(?) PDF document?
I have a need to test output of my code before I send the output for PDF rendering.
Currently I have decided on a switch statement that does two different things depending on whether I am in ...
0
votes
1answer
59 views
Abstract classes with static methods in PHP
Pre: I am looking at a quite big PHP project developed by a company which we need to partly interact with while building a new webapp.
The whole application is developed in PHP 5.
Most of the ...
0
votes
1answer
173 views
What is the name of this design pattern?
Magento has a class called Varien_Object with a pattern I'm trying to identify. The pattern creates hidden data and allows access to it but the main difference between this and a normal facade is ...
0
votes
2answers
142 views
Integration Tests - How much is too much? [duplicate]
First of I'm not sure if I chose the right name for my question, I'm not sure if
they are functional tests or integration ( or other ). I'm talking about tests which test (or it should) the app from ...
3
votes
2answers
92 views
Best practice in helper/util methods: IoC container or static methods?
So I'm developing an application which is using an IoC container. Now I need some helper methods for array manipulation like set, get, etc. I see two possible ways to go:
Using a class with static ...
-1
votes
1answer
94 views
PHP: where to call helper class in MVC?
I've a helper class in Laravel 5.1 with static methods for calculating week numbers, dates in weeks, etc. (Why static? I need max. 1 instance of this helper class)
I need this logic in my views. I'm ...
3
votes
1answer
115 views
Can this be considered an API? [closed]
I'm writing my first API, but I think I screwed it up from the design. It's a simple CRUD API which behave like this:
READ: /api/data gets redirected to api.php?data1=data. POST variables: user, ...
0
votes
1answer
144 views
How harmful is using switch(true) as a way to handle multiple conditional statements? [duplicate]
I recently saw something like the following:
switch(true)
{
case iAmAmazing():
{
return 'some html';
}
case isVariable:
{
return 'some other html';
}
case ...
-1
votes
0answers
22 views
oauth2, grant types, and mobile apps [closed]
I'm implementing a webservice which utilises oauth2
Specifically using this library:
http://bshaffer.github.io/oauth2-server-php-docs/
I have the beginnings of an android app that will access the ...
0
votes
1answer
54 views
Is it always better to use __construct() in CodeIgniter's Models and Views, even if it's not needed? [closed]
Sometimes we have Models and Controllers where the function __construct() just doesn't do anything, but is sitting on the top of all the methods in CodeIgniter's models and controllers. A lot of ...
3
votes
3answers
145 views
Evaluating data set with a string formula in php
I was tasked to update some conditions in an application.
I have a data set to be evaluated, and it has been hard-coded in the application following way:
$arr = array(
'a' => 'apple',
'b' => ...
5
votes
3answers
165 views
Comparing two large strings to see how much they match [duplicate]
Is there an easy way of comparing any two different size of string text to see how much percentage they're alike?
I'm trying this but I'm running into to this issue below. The left text area is the ...
0
votes
1answer
128 views
Webdesign MVC - going in the right direction?
I am trying to learn webdesign using the MVC design pattern. Right now, I am stuck at a point where my code gets more complex, and I am unsure about the structure and where to put which code parts.
I ...
3
votes
3answers
104 views
Which pattern can I use for doing computations involving similar yet different object subtypes?
How do I design code that has two qualities:
uses similar but different subtypes of an object
uses similar but different types of computation on the above objects
Example
I am refactoring this ...
0
votes
0answers
64 views
How does postback url works in campaign tracking systems?
my question is theoretical, a vague idea or some sort of algorithm will be great.
I am building an advertising campaign tracker web app for a friend, yet i am kinda lost, i cant figure out how the ...
0
votes
0answers
27 views
Compute geographic areas Laravel
I am developing a backend for a taxi app in Laravel 5.
Up to now, served areas are defined by the admins but I would like to change the way it works.
I would like each taxi driver to define their ...
1
vote
1answer
42 views
Laravel 5.1 creating model overrides per client
Okay, so I have a Laravel 5.1 project with close to 200 models. This is fine for the core operation of the app, however, in many cases a client may want us to grab something from the database in a ...