Questions tagged [php]

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

PHP is a widely-used general-purpose scripting language that is especially suited for Web development. The current stable version is 7.0.11, released on September 15, 2016

The online manual is an excellent resource for the language syntax and has an extensive list of the built-in and extension functions. Most extensions can be found in PECL. PEAR contains a plethora of community supplied classes.

PHP is often paired with the MySQL relational database. PHP also includes great database support for PostgreSQL, SQLite, Microsoft SQL Server (API ref), Oracle, IBM DB2 & Cloudscape, Apache Derby and even ODBC. All modern versions of PHP include PDO, a built-in data-access abstraction library with comprehensive connectivity options.

Useful Third-party Code

Frameworks

PHP has a variety of object-oriented web application frameworks, including:

(See: "What PHP framework would you choose for a new application and why?")

Object-Relational Mapping

Popular ORMs for PHP include:

(See: "Good PHP ORM Library?")

Unit Testing

Popular unit testing frameworks for PHP include:

(See: "Best way to implement unit testing in PHP")

Debugger and Frontends/IDEs

2049 questions
27
votes
6 answers

How to properly take over a complex PHP project

I've been tasked to correct some issues on the backend of a large website project that has been outsourced for some time. The original developers and us are not on good terms so it's not feasible to get them involved. The technology stack is as…
Robert H
  • 389
  • 3
  • 9
21
votes
6 answers

Directly modifying superglobals

I've seen people (who generally write good code) directly alter the $_POST array with code like this: // Add some value that wasn't actually posted $_POST['last_activity'] = time(); // Alter an existing post value $_POST['name'] =…
Mog
  • 744
  • 2
  • 6
  • 13
17
votes
1 answer

Why is PHP so hated?

Lately I've been coming across several jokes and comics about how apparently awful PHP is. As a complete ignorant of the language, why is this? Is it my own perception or is this the overall general feeling on the programming community?
Gabriel
  • 315
14
votes
7 answers

What are the benefits of PHP?

Everybody knows that people that have prejudices against certain programming languages. Especially PHP seems to suffer from problems of its past and some other things (like loose types) and is often called a non-serious programming language that…
acme
  • 579
  • 1
  • 5
  • 9
13
votes
2 answers

Is declaring fields on classes actually harmful in PHP?

Consider the following code, in which the setter is deliberately broken due to a mundane programming error that I have made for real a few times in the past:
Mark Amery
  • 1,250
  • 1
  • 14
  • 27
12
votes
9 answers

My university doesn't provide php courses because it is an "easy" programming language?

I've met a student from the computer science department and I discovered that they only teach java and aspx. I asked him why they didn't teach php since it is the top one programming language on the net. He says that it was a "easy" (or hobbyist's)…
wyc
  • 493
  • 4
  • 10
12
votes
1 answer

Do programmers keep error reporting on or off?

I was wondering if php programmers keep error_reporting in php.ini on or off after delivering the website?
user4124
10
votes
5 answers

When must arbitrary precision arithmetic functions be used in PHP?

My colleague uses the Binary Calculator functions in bandwidth calculations; as much as terrabytes, and with percentage splitting on allocation. His usage of these functions appears correct in order not to lose a byte; although he seems to be using…
9
votes
2 answers

Is mod_security a good thing?

I've recently been frequented by erroneous error messages from mod_security. Its filter sets cover outdated PHP exploits, and I have to rewrite my stuff because Wordpress&Co had bugs years ago. Does this happen to anyone else? Apache mod_security…
mario
  • 2,283
9
votes
1 answer

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' => 'orange', 'c' => 1, 'd' => 2, 'e' => 5, 'f' =>…
8
votes
1 answer

Is PHP7 a static or dynamic typed language?

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 Declarations (Note: Scalar Type Declarations repeatedly…
codez
  • 233
8
votes
4 answers

How does PHP5 fare with earlier versions of the language

I would like to learn PHP for web development but have been drawn back because of comments like the following*: PHP is good but generates spaghetti code PHP is nice but Python is marriage material PHP lacks stuff that you get in other languages…
Pankaj Upadhyay
  • 5,070
  • 12
  • 44
  • 60
7
votes
5 answers

WHat are the benefits of placing the concatenation character at the end or beginning of a line

Considering multiple lines of say SQL query strings: $sql = "select * from table ". "where a=5"; What do you think are the benefits and downsides of putting the concatenation character at the end or beginning of the line? This is to revise a coding…
jdog
  • 280
7
votes
3 answers

Is it safe to use CamelCased file names?

I'm developing a simple CMS which I'd like to make it open source. For the file structure, do you think it's safe to use names like: AppData FileUploads instead of app-data file-uploads ? Because I heard some servers have problems with the…
melania
  • 79
6
votes
1 answer

Trying to implement pre/post method code: better to use methods or a parent class?

I'm finding it difficult to frame this question so ... I want to execute code both before and after a method runs in PHP. There are, as far as I know, two ways to implement this: Method One: pre and post methods class Model { function find($id) …
Will
  • 281
1
2 3 4 5 6 7