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
6 views

Ajax copy text from one textarea to another via post

I am trying to use ajax to post the text from one text area to a php page to echo back into another textarea. When I do this it works for about 5 characters and then stops completely. I've tried with ...
-4
votes
0answers
24 views

Does google.com use php [on hold]

builtwith.com is a well known website used for discovering what was used to create a website. It says at http://builtwith.com/google.com that google.com uses PHP. Is this in any way true, and if not, ...
0
votes
1answer
31 views

Using PHP without mixing presentation logic

I'm conceptually designing a website / application and trying to come up with the correct separation of concerns. The basic technologies I'm settling on are: MySQL, PHP (Laravel), HTML/JS (jQuery). ...
0
votes
0answers
25 views

Optimizing instant notifications

Scenario To deliver instant notifications to the client, I'm sending an AJAX request to a PHP page that checks if there are new notifications: if there are, it outputs them, otherwise it sleeps for ...
0
votes
0answers
54 views

How to use a href link just like a button? Which can perform some event? [on hold]

I need the help in web programming concept. I want to create a link which will perform a login redirection. I want a reader view which will display some information To perform login we have to open ...
1
vote
1answer
40 views

composer is self-described as inspired by npm, so why does it handle sub-dependencies differently? [on hold]

As I'm sure anyone reading this knows, the default behavior for npm is to install sub-dependencies within their respective sub-dependency directories themselves (in a new node_modules directory). The ...
-1
votes
0answers
24 views

Live feed statistics to website [on hold]

I am trying to create a live display of all of my analytics accounts such as Twitter, Facebook, GPlus, Google Analyitics and a few others. The idea is to display all of these on a personal area of a ...
-1
votes
0answers
21 views

Accessing large lists of words PHP Array or MySQL [on hold]

I'm creating an application that grabs a list of words, and mashes them together. Example: Hello, World, Coding Output: Helld, ingdld, Codrld I want to have many lists of words. I originally was ...
-5
votes
0answers
34 views

How else can I write the following code to generate C code and then the user submits a C file to the database? [on hold]

How else can I write the following code to generate C code and then the user submits a C file to the database? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ...
0
votes
0answers
13 views

Controller technique with request data in session

I am trying to find out the best possible way to save the POST data in session and making it available in different page requests. For example at website's homepage I have a Search form with ...
-4
votes
0answers
37 views

How to solve numbers combinations using php [on hold]

I am using this php code # for ($pvalore = 1; $pvalore < 91; $pvalore++){ for ($stepvvx = $pvalore; $stepvvx < 91; $stepvvx++) { $stepvvx2=$pvalore; if ...
0
votes
0answers
26 views

How can get the responce with multi object classes using simplexml? [on hold]

Im trying to get the responce from https://api-dev.learningassistant.com/webservices/soap/enrolment.cfc?wsdl But sad to say the xml file for request are more complicated. My problem is how can I ...
-4
votes
0answers
26 views

Form not saving data to MySQL Database [closed]

Please let me know how I can save the form data to my MySQL database. Currently I am using the following codes: the html form: <form id="signup-form" method="post" action="save.php"> ...
-2
votes
1answer
51 views

Less PHP request to REST API

I had an argument with my PHP developer today who tried to convince me that REST API has to provide all the request from PHP since a server is faster than client devices such as desktop. As I am a ...
3
votes
1answer
51 views

PHP mysql checking for relational equivalence

Suppose I have a users table and in that users table I have a role_id. In my roles table I have: users - id - role_id roles - id - name roles id | name 1 | admin 2 | normal Now ...
0
votes
1answer
36 views

Class member access on instantiation without variable

With a new feature in PHP 5.4, we can access a class member on the same line as instantiating the class. e.g. // Instead of $obj = new myClass(); $obj->myMethod(); // PHP 5.4 allows $obj = ...
2
votes
2answers
119 views

Handling insertion to database with Repository pattern

I have a design question for working with databases in object-oriented PHP. I have a table in my database called products. Then I have 2 classes for this table in my PHP project. ...
3
votes
1answer
356 views

What does comma signify in a function definition?

From PHP manual: array array_change_key_case ( array $array [, int $case = CASE_LOWER ] ) What does comma signify in a function definition?
1
vote
1answer
56 views

What's the difference between a Factory method and Entity Translator

The entity translator provides a function that takes one or more data contract classes as parameters and returns a specific business entity. Within the implementation of the function, a new ...
0
votes
1answer
243 views

Accessing database from static and non-static methods

I'm currently building a REST API in PHP & MySQL, and now I'm stuck at how I should structure the classes and the database connection. Let's say I have a table in my database for movies. How ...
1
vote
2answers
68 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: ...
-2
votes
0answers
34 views

PHP mysqli adding multipe entries for one insert [migrated]

the following short PHP code should be adding 1 entry into the database table. however when I run this I find 3 identical entries. MySQL Server version: 5.5.39 - MySQL Community Server PHP/5.4.31 ...
3
votes
1answer
160 views

Application requires specific PHP version, but code to check if version is adequate cannot run if version is not adequate (chicken and egg problem)

A framework I'm writing (for learning) requires a specific PHP version to run, so I'm implementing a "PHP version check" to ensure the running PHP version is the minimum required for the framework. ...
1
vote
2answers
296 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: ...
0
votes
0answers
70 views

Best practices to prevent DoS attack, PHP running bash script on apache server

I have a PHP page the sole purpose of which is to spawn a bash script to run some background code (10-15 seconds run time), and then forward to a second page. The second page waits for the background ...
0
votes
1answer
53 views

Algorithm to maintain a blog sign up page

I have a functional sign up page for a blog that updates a database with a users name, email, profile picture and a short bio. The General information page and the profile picture upload/bio page are ...
-1
votes
1answer
37 views

Cookie name security

Is it a security hole to name each session with the username of the user currently logged in? example: //Alice has login sessions_name('Alice'); sessions_start(); //Alice has login //When Bob Logs ...
1
vote
3answers
142 views

What is a good Design Pattern for a bundle of methods that comprises an algorithm?

This is a Design question relating to finding out a good OO design pattern or design structure or class combination that can house an algorithm that processes user selection to produce product ...
0
votes
0answers
35 views

Utilizing Python Slate for pdf text extraction from PHP

I want to use Python Slate module for PDF text extraction, and I have my code up and running for this. What I would like to know here is how to link my existing PHP MVC to utilize/make a request to ...
-1
votes
0answers
58 views

should we also develop our PHP backend as an API? [duplicate]

I found a really interesting question here (ASP. NET). And I would like to know if we should think about the same concept on PHP? This seems to me portable with ease. Maybe there are already basic ...
0
votes
3answers
240 views

How can I keep browser URL secret when editing data?

Suppose, There is a user list. <a href="user/5">Edit</a> <a href="user/6">Edit</a> When a system user clicked to edit a user info. Then it goes to url to browser like as ...
-2
votes
0answers
54 views

How to pass view data to controller? [migrated]

I want to create sample web app using php mvc but don't know how to pass view data (login.php) to controller (userController.php) My view (login.php) <body> <form ...
5
votes
1answer
137 views

How to prevent multiple form submissions when user reloads the page

I'm currently working on a project which requires that we integration a 3rd party SOAP API to handle a number of basic CRUD type operations. Our current implementation allows us to leveraging the ...
1
vote
1answer
67 views

DTOs vs Domain Models and invoking Command Handlers directly

I was just hoping someone might be able to answer a few questions I have regarding the proper design of DTOs and Domain Models. I'm currently working on a project which involves leveraging a SOAP API. ...
0
votes
1answer
53 views

Implementing SEO for a Zend Framework/PHP/Angular.js application

A team has implemented a web application using MySql, PHP with the Zend framework and Angular.js on the client side. I am in charge of implementing the SEO for this application. I understand I have ...
1
vote
1answer
49 views

How to use DataMapper pattern methods, when loading data from database?

How do I use DataMapper Pattern? I can use it as a glorified Database Access Object, aka TableGateway (loading a single class from a single database table), or I can use it more to drive business ...
1
vote
1answer
99 views

PHP filesystem best practice

I'm writing a PHP script which communicates with another program via files. I wonder if there is some policy or standard on where to put such files? I assume choosing a path like C:\foo\bar\ isn't the ...
1
vote
3answers
82 views

Where should PDOExceptions be dealt with?

I wrote a database wrapper class to help with queries and I'm trying to figure the best way to implement try-catch blocks. In my database class, I have a helper function; public function ...
3
votes
1answer
48 views

Can I resolve an issue with SRP, SOC that prevents object initialization via constructor?

In OOP, I can populate (initialize) an object using constructor injection at object creation time, or setter injection, after creation time. I like the idea of populating object at creation time via ...
2
votes
1answer
56 views

Why is SRP using the class construct to contain a responsibility opposed to using any other OOP entity?

SRP states ... There should never be more than one reason for a class to change. But why a class? Why not use granularity of a function/method? What instead of separating my functionality into ...
1
vote
1answer
69 views

Is it safe to only use intval to sanitize user input for a database select?

Is it safe to only use intval to sanitize the user input for a database select, as in the following example? $id = intval($_GET['id']); $query = "SELECT * FROM table WHERE id='$id'";
-1
votes
0answers
71 views

When should mixed PHP/JS snippets be refactored into a separate JS file? [duplicate]

This code snippet is from a teammate of mine, his title is "Full Stack Developer". He mostly write PHP code. I found this code at the end of a .php file and asked him to move it to a separate JS file ...
9
votes
2answers
561 views

Is automatically generating passwords during registration a good idea?

I'm developing a registration system for a project I'm working on. Since users tend not to sign up if the process is too long, I've thought to require (at least initially) just their email, where I ...
-7
votes
3answers
159 views

Why different languages have different syntax? [duplicate]

Different programming language always/most of the time use different syntax. For example take PHP, Java and Python. In Php & Java semicolons are compulsory at the end of the line, yet Python ...
2
votes
2answers
128 views

Does it break SRP to have concerns of data handling and object mapping inside a single class, as part of the DataMapper pattern?

Summary I want to look into separating the concern of "creating a populated object from database", to use inside my application. DataMapper pattern seems to be doing just that for me. DataMapper ...
4
votes
3answers
258 views

What's special about “non-blocking” node.js?

In the short chapter, What is Node by McLaughlin, he writes: "Node has no blocks, no threads competing for the same resource (Node is happy to just let things happen however they happen), ...
0
votes
0answers
2 views

What is the fool-proof way of setting up spreadsheet_excel_writer on Windows Server 2012 R2 [migrated]

I have an financial projection and budgeting application that produces spreadsheet outputs. This is working fine on Linux OS, with PHP 5.5.12 and also Spreadsheet_Excel_Writer 0.9.3 and OLE 1.0.0RC2. ...
0
votes
0answers
45 views

What are PHP Worker (with functional example)

I was handed a PHP Project to maintain and after going through the code, I think some tasks can be off-loaded to increase efficiency and create some compartmentalization. Our app runs on Heroku and I ...
0
votes
0answers
32 views

BCMath vs MySQL: performance

Scenario I am working on a web application that handles financial transactions, and my code will need to be reusable for everything from consumer carts to manufacturer/distributor shipments. The ...
3
votes
1answer
99 views

PHP Refactoring advice

I'm working on a Soccer management game. Project is fairly new and small and I'm new to PHP. The project was starting to get a bit messy so I've been looking into refactoring. The first thing I've ...