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

learn more… | top users | synonyms

-2
votes
0answers
14 views

How to retrieve a single user data that is owned by the user who log in using session in CodeIgniter? [on hold]

I'm new to CodeIgniter. My problem with my code is that, when a user logged in to his/her account, he can't view his/her details, instead, the detail of the first row from the table where I fetched ...
0
votes
1answer
34 views

Send request from a computer, wait for response from another, then trigger an action on both, with PHP

I have a website project that is planned to work as the following: User #1, who is registered on the site, sends an invitation for some activity (whichever activity, like playing a game, etc.) to ...
0
votes
2answers
78 views

Selecting between multiple actions in PHP

I have been programming for a number of years now and in PHP for about 4 of those years. I have always wondered what is the best approach when it comes your program deciding what action to take based ...
-4
votes
0answers
30 views

Need help in choosing PHP frameworks for my web application (which is similar to freelancer website) [on hold]

I am planning to build a web application similar to functionality as freelancer. I am basically a asp.net developer. But I have chosen PHP as the language of choice to code my web application. I have ...
-3
votes
0answers
32 views

array loop never stop [on hold]

<?php $ulang = true; for ($i=1; $i <=3 ; $i++) { for ($j=1; $j ...
2
votes
1answer
163 views

Hidden dependencies - why not?

Hidden dependencies: function __construct($dep_registry){ $this->db = $dep_registry->get('db'); $this->request = $dep_registry->get('request'); ... } Not so hidden: function ...
1
vote
1answer
106 views

Using exceptions as regular objects [duplicate]

I have views that handle different errors in my application. For example error 404, 403 and such, giving my errors a more user-friendly presentation. By assumption, they get passed in an exception, so ...
-4
votes
0answers
25 views

Inserting file_path into database using Codeigniter [on hold]

I am new to Codeigniter, so having some confusing on this proccess: I have a form field where user can upload any jpg|png|gif file ,the uploaded file is successfully sent to a uploads directory and a ...
0
votes
1answer
45 views

Test logic with external data [duplicate]

I have a site programmed in PHP where I make more call to external server that return me big xml of data. For each record of the xml I have to make other external call to get other data. So my ...
-4
votes
0answers
129 views

PHP vs Python. Which is best for me and my situation? [on hold]

As a beginner programmer, should I learn PHP or Python? I know this has been beaten to death but I would like opinions based on my specific situation. Programming Background - I am a complete newbie ...
0
votes
1answer
80 views

Multiple method calls in the constructor and dependency injection

I was asked to refactor some almost ureadable spaghetti code into object-oriented architecture. I have some doubts regarding a class that I designed. Here is the class' skeleton: require_once ...
0
votes
1answer
39 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) { ...
-4
votes
0answers
22 views

visual basic: get php Query from text box [on hold]

How can I get url Query from text box and put it line by line in richtextbox. exemple: I want to get query from textbox1.text : and put it in richtextbox or multilines textbox line by line : ...
0
votes
0answers
22 views

Will turning error reporting and error display on and off throughout the stack cause a problem with PHP

I want to turn error reporting and error display on and off for different parts of the same framework (same stack and scope). ini_set('display_errors', 'On'); Changing to 'Off'. ...
2
votes
2answers
121 views

How to store data in memory(RAM) using php without using Memcache/Redis or any other software? [closed]

I want to implement a cache system in PHP consisting of following features 1) It should be able to store any(large or small) amount of data as long as the memory serves.(key value pair i.e. get & ...
1
vote
5answers
335 views

Are there too many parameters in this constructor? [duplicate]

Check this out: public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, ...
4
votes
3answers
162 views

Better way of manipulating large objects

I am doing a lot of work with SOAP Api in PHP and the objects that are returned are quite big. I am then updating the objects from local db changes and pushing them back. So more often than not I ...
1
vote
0answers
47 views

How to off load DB & API calls (PHP Heroku App) [on hold]

I took over support for a PHP app that runs on Heroku. After analyzing the performance with New Relic, I'm noticing that the three bottles necks are the database and API calls to outside services. ...
1
vote
1answer
217 views

Is this a race condition?

I have a friend arguing this is a race condition, but I'm struggling to understand how. This is for a web application using PHP and MySQL where users can login and create tickets, these tickets have ...
1
vote
1answer
75 views

PHP OOP: value property is guaranteed different?

Imagine this code: class Test { public $result; public function makeSum($a,$b) { $sum = $a+$b; $this->result = $sum; } } In a webserver. At same exact moment, ...
0
votes
1answer
90 views

Does the phrase “range for R1-1 through R10H” actually have an agreed-upon meaning?

I was recently sent a code test by a potential employer to complete on my own time. The first question has to do with identifying whether a given zoning code falls within a range of codes. I'm not ...
1
vote
2answers
99 views

Can i write html on one line only in my php code?

i need to embed a html 301 redirect in my php code and i wanted to save chars in my html. Can i write HTML on one line since it is parsed? Is there anything against this practice? ?> <!DOCTYPE ...
0
votes
1answer
67 views

Are there any strong reasons to use DI for sub-classes that are known to be tightly coupled to their parent containers?

I have Product classes for Products A through Z. And each Product class has its own set of product-specific subclasses, which I'd say are tightly coupled to them, like so: //specific product class ...
0
votes
1answer
65 views

php Database operations in separate files?

I have a single page application. Select boxes need to be filled with select queries from the database. How do I structure the application? Currently I have a file add_details.php. It contains a ...
0
votes
2answers
101 views

Should I extend an interface or keep it independent?

I'm trying to decide whether to extend a base interface with additional methods or create several independent interfaces. I have a Task interface that looks like this interface Task { public ...
1
vote
1answer
50 views

Laravel using models

I started working with Laravel about a month ago and I started by reading the documentation etc. Now I'm working on a project in Laravel 4.2 and I skipped some parts of the full documentation. In my ...
-1
votes
1answer
50 views

keeping of all javascript functions in one place [duplicate]

In php website I am using different javascript functions in different pages for example page a calls functions 1,2,3 and page b calls functions 2, 4, 6 and page c calls functions 3, 6 can I place ...
1
vote
1answer
88 views

Calculating winning probability for 2 teams using their history?

So I'm working on this project where I have a database full of team winning history. For example let's say these are all football teams. Every match has 2 participants (2 teams) and always a winner. ...
2
votes
1answer
170 views

Laravel 5 Multi-App

So my work has a dashboard built in codeigniter where every app on the dashboard has its own subfolder in controllers / models / views and nothing is shared. I have been tasked with upgrading this to ...
0
votes
1answer
100 views

2 Classes that share similar behaviours but unrelated.

I'm working on something at the moment and am a little confused. I'm working on an enquiry system in PHP (it's Opencart Based, so MVC). An enquiry comes in and depending on what form it was ...
0
votes
0answers
2 views

PHP/SOAP - How to print multiple results [migrated]

I'm trying to parse the result in PHP from a SOAP request. Sometimes the response can be in a single object, but sometimes it can be multiple array results, and then my PHP breaks. If it's only a ...
1
vote
3answers
183 views

OOP implementation doubts with databases

I was starting a project today and after designing the database structure and how the data would be stored etc, I started the implementation. I am doing this on php, but the language isn't really ...
0
votes
0answers
39 views

Calculate the time remaining until a subscription [migrated]

I have a subscription that can be subscribed to every month, every two months or every 3 months. That's represented as a subscription_frequency of 1, 2 or 3. I then have a month_joined property (1 ...
1
vote
2answers
77 views

How to organize code which converts from one type to another

If I have a DateRange class, and I want to translate a DateRange into SQL (e.g. some_col >= '2015-3-5' AND some_col <= '2015-3-5'), where should I put the method that does the translating? ...
2
votes
1answer
174 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 ...
0
votes
0answers
16 views

problem with “real_escape_string” [migrated]

i am having some troubles my the "real_escape_string" and i need some help login.php <?php include('Connections/local.php'); ?> <?php function GetSQLValueString($sql) { $sql = ...
0
votes
2answers
51 views

Executing scripts in parallel based on dependency tree

We have an app that is using a fairly simple stack (Linux, PHP, Oracle, Shell Scripts, etc). We have a series of scripts that need to be executed: /scr/app1/start.sh /scr/app2/start.php ...
0
votes
0answers
4 views

How do I remove spammy links in WP theme footer? [migrated]

I got a little obstruction. I have a free theme, which I like, but I found out that in the footer there are too many commercial links (Let me say spammy links). I want to keep the credits to the ...
-1
votes
1answer
54 views

Laravel - BLOB File Management System - Possible obstacles?

I'm working on this weird project where I need to upload huge files (500mb+) and store them in a postgresql table as a blob. Before you start telling me that storing files in the database is bad and ...
0
votes
1answer
89 views

Best way to centralise a php project (except bitbucket)

The structure is as follows: A: this is the live/production website B: this is the staging, which is a copy of live C: this is the testing environment for designers 2 developer and 2 designers. ...
1
vote
0answers
36 views

Prevent Timeout for large scripts without changing any System Settings

Current Option If I have a process that I know may take a while I have been chopping it up using ajax to do a part of the request then once the ajax is returned do the next part of the request. This ...
0
votes
1answer
64 views

Where to put utility classes in php mvc?

I'm working on my first MVC website, where can I put utility classes like Security and Date (my native date) classes, are they model too? App | |--- Model |--- Controller |--- View
1
vote
1answer
32 views

PHPUnit > Best approach to mock container objects? (e.g. $item->id)

I'm using PHPUnit test doubles to mock models, libraries etc. But when I want to return an array perhaps of container objects, how best to do so. Here is what I'm currently doing: /** * This is just ...
1
vote
1answer
47 views

PHP MVC Model with a method to fetch all of the model from database

I have a crazy question, consider I'm developing a blog website, There is two model named Post and Comment, now I wanna add a method to fetch all comments from database, which model should I choose to ...
0
votes
0answers
13 views

How to push data from one page to another [PHP] [migrated]

I'm using sockets.io, express and php and I was wondering if it is possible to push something of a page (that only a specific user can see at the time) to another page other can see. For example, if ...
1
vote
1answer
144 views

Need to store Multiple Images (path) into MySQL after upload [duplicate]

I am trying to build my own little eCommerce CMS, and i want the expert opinion on how to handle multiple uploaded files (images). For Example: A user adds a new item, fills the necessary form data ...
0
votes
2answers
300 views

Storing and retrieving simple data within a framework

I'm determined to get a decent answer to this, because while I have my own approach (constants) I'm not convinced I'm doing it as efficiently as I could be. So I'm editing the entire question, to ...
1
vote
0answers
50 views

Preserving Pre-formatted Multi-Line Strings in Node.js Scripts

There is a lot I don't like about PHP, but one thing I love is multi-line strings: $query = <<<EOT select field1 ,field2 ,field3 from tableName where field1 = 123 EOT; ...
0
votes
1answer
85 views

Database object mapping, good practices [closed]

I think I've understood the basic idea behind object mapping but there is one gap in my knowledge base that I hope to fill now. First let me tell you what I understand out of the whole thing. I have ...
2
votes
1answer
84 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 ...