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

learn more… | top users | synonyms

-1
votes
0answers
34 views

Basic PHP Factory Pattern code review

I have an object, KbArticle, that originally in it's constructor, would try to return null if the SQL query that retrieves the data for its required properties came up with 0 rows. A friend told me ...
1
vote
1answer
91 views

What is the simplest archive file format to aim for when writing collections of files?

I've created a PHP-based document management system and hosted it on my Raspberry Pi. I created a "backup" function that zips together all the documents, but it takes too long due to the hardware ...
2
votes
2answers
190 views

What's a good simple way to combat the n+1 problem?

I'm trying to better understand performance in PHP. One issue I'm thinking about is the n+1 problem. By n+1 I mean something like this: $posts = Posts::getPosts(); foreach($posts as $post) { ...
1
vote
1answer
82 views

Repository pattern implementation that knows nothing (Jon Snow) about the database table and column names

I've seen around the Internet and Github, implementations for the design pattern Repository that knows about database table and column names. I was think, if I want to work with the database as a ...
-1
votes
1answer
69 views

PHP4 constructor does not work with namespaces [on hold]

Here's a scenario: whenever accessing class using namespaces in php, it doesn't launch the standard constructor, but only the 'magic' method. What's wrong here and what can be fixed? hierarchy ...
0
votes
0answers
19 views

Doctrine 2 and Concrete table inheritance

I use Doctrine 2 and I've read some articles on inheritance strategies' mapping with ORM. I've seen three main strategies : "Class table inheritance", "Concrete table inheritance" and "Single table ...
0
votes
1answer
64 views

How can I cancel all running mysql queries in a web application?

I am running a web application which has to scan (mysql query on a particular column) a huge MySQL table, which has over 100,000 records. The problem I find that when a user requests another page ...
-2
votes
0answers
96 views

How to convert some paragraph to html codes with using some symbols for each tags [on hold]

RESOURCE: web page url: "http://en.wikipedia.org/wiki/Anarchism" Text file equivalent to above url html content (Some part of the content, not fully): '''Anarchism''' is a [[political ...
-2
votes
0answers
18 views

Regular expression(preg_replace) in php [duplicate]

I tried below code for replace some text with regular expression pattern..but i cant get properly: Following scenario: My input 'the is good [[text]] [[link1|text1]] [[link2|text2]] [[text]]' ...
1
vote
1answer
93 views

AJAX or web sockets for client-server communication?

I recently took a course on AngularJS, and quite frankly I loved the concepts of a website that fetches json to handle subsequent requests, however I still feel like Javascript is far too slow for ...
-5
votes
0answers
38 views

Regular expression in php [on hold]

$patterns = array ('~\[\[(.*)(\|)(.*)\]\]~U','~\[\[(.*)\]\]~U'); $replace = array ('textpluslink','text'); echo preg_replace($patterns, $replace, 'the is good [[text]] [[link1|text1]] [[link2|text2]] ...
1
vote
2answers
122 views

How do two applications communicate? [on hold]

Say I had a PHP page with a calculator interface, but I want to transfer the sum to Windows Calculator.exe and then get a reply from the application back to my PHP page, how do you go about doing ...
-2
votes
0answers
11 views

Convert symbols to html tags in php [migrated]

<?php //Read file $file = 'sample.txt'; $file_copy = 'sample1.txt'; $homepage = file_get_contents($file, NULL, NULL,10); echo htmlspecialchars($homepage); //Write file $current = ...
1
vote
1answer
54 views

Repository Pattern: Doctrine2 vs Microsoft Entity Framework?

I have been using Symfony2 with Doctrine2 for some years. I have recently started using Microsoft's Entity Framework with MVC5. From my Symfony2 experience I understand that a repository's job is only ...
-2
votes
0answers
40 views

Checking against database for various conditons: PHP [on hold]

I am new to PHP programming and getting learned as I do this project. The first phase of the project needed to get all the profile information (id, name, code, date, etc…) under different customer ...
1
vote
0answers
94 views

MVC content management framework with an admin panel

I've lately been developing my own MVC content management system using PHP and, at least in my mind, am a little stuck with the system design. I believe this would apply to building a content ...
-1
votes
0answers
18 views

how to create a SIP request with specific header fields values [closed]

I'm an intern at a telecommunications operator and my task is to create an application that enables me to send sip (session initiation protocol) requests with the header fields values that i specify , ...
-5
votes
0answers
58 views

Return statement - ends a loop? [closed]

Hi please check this php code: <?php $arr = array('first'=>1, 'second'=>2, 'third'=>3); function returnElement($arr){ foreach ($arr as $key => $value) { if($value>1) return ...
-1
votes
0answers
28 views

Database/Storage engine for a project involving heavy inserts? [closed]

I am looking into a project which involves large number of inserts daily.I will have a list of user's (for example a user set of 500k ) , for which I need to monitor daily certain activities ...
1
vote
1answer
144 views

Should we live by using Suhosin with PHP?

A lot of my security experienced friends have told me that I need to code my web applications for working under the Suhosin PHP patch, Suhosin being "an advanced protection system for PHP ...
0
votes
0answers
54 views

PHP Password_Hash Function [migrated]

I've been reading up on the usage of the PHP Password_Hash Function it states that it automatically generates a salt and manually generating one is not advised. With this in mind, does this mean I ...
2
votes
0answers
67 views

Use and manage Front End Assets for Web

I am a beginner and am currently developing a kind of cms using PHP. The number of libraries that we can potentially use in the front end is large. I have a question about properly selecting, ...
-1
votes
0answers
20 views

How to access the nth object in a Laravel collection object? [migrated]

I have a laravel collection object. I want to use the nth model within it. How do I access it? Edit: I cannot find a suitable method in the laravel documentation. I could iterate the collection in ...
-1
votes
1answer
79 views

Cloud Newbie … what should I know while creating my App [closed]

I never developed for the Cloud, and to tell you the truth I am not fully 100% sure of what Cloud is when coming down to servers and services. I am starting to develop an App where I will need to be ...
-1
votes
2answers
176 views

Is PHP the only popular language that mixes simple and associative arrays into a single type? [closed]

I'm doing a research on PHP and wondering if there any other commonly used programming langues that use an associative array for both simple indexed element storage and key-value functionality. Does ...
1
vote
1answer
65 views

Web Application: Combining View Layer Between PHP and Javascript-AJAX

I'm developing web application using PHP with CodeIgniter MVC framework with a huge real time client-side functionality needs. This is my first time to build large scale of client-side app. So I ...
0
votes
1answer
71 views

When to used static visibility? [duplicate]

I can't attain the primary used of Static Visibility. My question is why they used static method & properties in this code? class PassHash { // blowfish private static $algo = '$2a'; ...
0
votes
0answers
6 views

Bootstrap Active tab on modal hidden [migrated]

I am using Bootstrap as Framework for designing a form, the form has fields in several tabs, I added a onSubmit event that displays a modal if there are any empty field cancels the submit and focuses ...
-1
votes
1answer
27 views

php and mysql hosting service that fulfills my registeration system [closed]

Kindly tell that how to make a registration system that work with php and MySql . I tried the demo that is here but how it works with the online web hosting . I have registered the free hosting at ...
0
votes
0answers
79 views

A kind of actions handler on my PHP project? [migrated]

I wanted to do something like actions handler. I don't know how it should look like. But I started to make something like that: MySQL: CREATE TABLE `handlers` ( `name` varchar(65) NOT NULL default ...
-2
votes
4answers
224 views

What is the name of this design pattern? [closed]

I have been using this "design pattern" (may or may not be an "official" design pattern) for a while and I wanted to know if it had a name (so that I could name my classes after it). Example in PHP ...
0
votes
0answers
26 views

Laravel 4: Binding/linking two users together

I'm building a unittest system. At some point I want to bind two users together in order to make an assignment for those two. So when the admin chooses to link two students together the system should ...
1
vote
1answer
85 views

Taxonomy / Classification of real world objects. Development suggestions [closed]

I have to develop a taxonomy/classification program based on classification algorithms and i would like to have some suggestions. The aim is to help the one using the program to categorize an object ...
0
votes
0answers
14 views

Writing Models in PyroCMS/Codeinighter Models

In Pyrocms there are Admin views and User views. Im developing a complex module where my model file is getting to be rather large. Should I be abstracting logic in my model files to also be User ...
0
votes
2answers
120 views

Flaws in my PHP development setup - sharing sources causing lags

I have following development setup for my PHP projects: Working station running on Windows 7 with PhpStorm IDE. GIT for version controlling. CentOS on virtual machine (VirtualBox) with Apache and ...
0
votes
2answers
134 views

Failed to allocate memory - What is it trying to say?

In my early days of programming I often used to get memory related fatal errors in the following format: Fatal error: Allowed memory size of <some big number> bytes exhausted (tried to ...
0
votes
1answer
133 views

Face Recognition(OpenCV) with MySQL and PHP

First of all I have asked this question on stackoverflow and got down vote for question being not belonging to the site. I am trying my luck se now(more suitable to se I guess) and I hope I will not ...
-1
votes
0answers
5 views

Creating PHP Forms with show/hide functionality [migrated]

I want to create two reports and submit the report data to database by using two functions defined in a class: Here I have two buttons: "Create ES" and "Create RP". Rightnow, my forms are working ...
1
vote
1answer
185 views

Advice on refactoring PHP Project

I have a small SAS ERP that was written some years ago using PHP. At that time, it didn't use any framework, but the code isn't a mess. Nowadays, the project grows and I’m now working with 3 more ...
7
votes
1answer
129 views

Securely sending data from shared hosted PHP script to local MSSQL

I'm trying to add data from a webhook (from a web cart) to a local Microsoft SQL Server. It seems like the best route for me is to use a PHP script to listen for new data (POST as json), parse it, ...
2
votes
1answer
75 views

Do objects maintain identity under all non-cloning conditions in PHP?

PHP 5.5 I'm doing a bunch of passing around of objects with the assumption that they will all maintain their identities - that any changes made to their states from inside other objects' methods will ...
1
vote
1answer
27 views

Correct process for creating builds reliant on 3rd party packages

I work on a Symfony 2 codebase. We use a number of third-party packages (most are in the Symfony Standard Edition). We use composer for dependencies. We current have all of our third-party code ...
0
votes
0answers
73 views

Penny auction concept and how the timer works

I am creating a penny auction site using PHP yii framework. The main consideration of the system is to update the database records of all active auctions (max 15 auctions) with the current ticker ...
0
votes
1answer
136 views

Website File and Folder Structure

I am having a problem learning how proper website structure should be. And by that I mean how to code the pages and how folder structure should be. Currently I am navigating around my website using ...
0
votes
1answer
52 views

exception for string literal conventions

If I'm used to use ' for string literals in PHP, would it be better if I'll stick to it in any situation or can there be exceptions when it would increase readability? example: $foo = "bar'baz"; // ...
0
votes
0answers
76 views

Static methods and static functions? [duplicate]

I want to call a function in a static context in a class. For instance: class test { public function a1() { //do something... } public static function a2() { . . . $this->a1(); } but $this is ...
0
votes
0answers
43 views

ffmpeg: cut multiple input files with seeking to one output file

I have list of video files (loaded from database), each with start and end time of requested interval: # file begin end v1.mp4 1:01 2:01 v2.mp4 3:02 3:32 v3.mp4 2:03 5:23 And ...
0
votes
2answers
340 views

Why elseif instead of else if?

Few days ago I stopped on some PHP's developers quide (for contributors to particular project) and it stated, that elseif must be strictly used instead of else if -- without giving any reason, why? ...
0
votes
2answers
104 views

Image caching when rendering the same images on different pages [closed]

I'm told to think about caching of images that will be displayed on the page. The images will be repeated throughout the website on different pages and I'm told to figure out the best way to cache ...
1
vote
0answers
104 views

Websockets VS SSE

Suppose I have a service which requires to seek the database for different data once and in a while. For this I have 2 or 3 SSE, each one with a different retry basetime (20000 miliseconds, 1000 ...