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

2046 questions
109
votes
7 answers

You're hired to fix a small bug for a security-intensive site. Looking at the code, it's filled with security holes. What do you do?

I've been hired by someone to do some small work on a site. It's a site for a large company. It contains very sensitive data, so security is very important. Upon analyzing the code, I've noticed it's filled with security holes - read, lots of PHP…
MaiaVictor
  • 5,820
  • 7
  • 27
  • 45
94
votes
5 answers

Naming classes, methods, functions and variables

There are 3 important naming conventions: with_underscores PascalCased camelCased Other variants are not important because they are not commonly used. For variables it seems that the one with underscores is the most used by developers so I'll…
Alexa
  • 1,281
  • 1
  • 11
  • 9
88
votes
63 answers

What features would you like to have in PHP?

Since it's the holiday season now and everybody's making wishes, I wonder - which language features you would wish PHP would have added? I am interested in some practical suggestions/wishes for the language. By practical I mean: Something that can…
StasM
  • 3,377
  • 2
  • 23
  • 28
66
votes
4 answers

What's the dominant naming convention for variables in PHP: camelcase or underscores?

The consensus seems to be that one should follow the convention of the platform they're developing for. See: Underscore or camelcase? Naming conventions: camelCase versus underscore_case? However, PHP doesn't seem to strictly follow any convention…
Stas Bichenko
  • 3,689
  • 4
  • 24
  • 32
65
votes
21 answers

"Don't do programming after a few years of starting career". Is this a fair advice?

I am a little experienced developer having approximately 5 years experience in PHP and somewhat less in Java, C# and trying to learn some Python nowadays. Since the start of my career as a programmer I have been told every now and then by fellow…
Yasir
  • 1,229
  • 3
  • 13
  • 14
59
votes
12 answers

Is it considered bad practice to have PHP in your JavaScript

So many times on this site I see people trying to do things like this : I don't…
Greg Guida
  • 737
  • 1
  • 6
  • 11
58
votes
3 answers

How can I test PHP skills in a interview?

My company needs to hire a PHP developer, but nobody has PHP knowledge in my company and we find difficult to test for PHP skills. If it were a C/Java developer I would ask him to write a quick implementation of the Game of Life, but PHP is a…
Mascarpone
  • 765
  • 1
  • 6
  • 8
55
votes
11 answers

Is there a general solution to the problem of "sudden unexpected bursts of errors" in software?

Let me explain what I mean. I have made a complex, highly polished over years PHP framework/library for my own use. I very aggressively log the smallest notice and immediately deal with it as soon as it pops ups, always trying to predict potential…
user379490
  • 675
  • 1
  • 4
  • 3
50
votes
5 answers

should I throw exception from constructor?

I know I can throw exception from constructor in PHP but should I do it? For example, if a parameter's value is not as I expected it. Or should I defer throwing an exception till a method is invoked. What are advantages and disadvantages in both…
WordsWorth
  • 621
  • 1
  • 6
  • 9
46
votes
5 answers

When to use PHP or ASP.NET?

I have worked extensively in developing web applications using PHP and ASP.NET, but one of the questions that I'm constantly asked by customers is whether to move forward with a php website or an asp.net website. So naturally the first thing that…
Edward
  • 2,149
  • 4
  • 19
  • 24
46
votes
8 answers

Is it common practice to validate responses from 3rd party APIs?

I'm working on a PHP web application that depends on a few 3rd-party services. These services are well documented and provided by fairly large organisations. I feel paranoid when working with responses from these API, which leads me to write…
45
votes
7 answers

Type casting variables in PHP, what is the practical reason for doing this?

PHP, as most of us know, has weak typing. For those who don't, PHP.net says: PHP does not require (or support) explicit type definition in variable declaration; a variable's type is determined by the context in which the variable is used. Love…
Stephen
  • 2,200
  • 6
  • 22
  • 24
44
votes
6 answers

Why does Facebook convert PHP code to C++?

I read that Facebook started out in PHP, and then to gain speed, they now compile PHP as C++ code. If that's the case why don't they: Just program in c++? Surely there must be SOME errors/bugs when hitting a magic compiler button that ports PHP to…
user72245
  • 557
  • 1
  • 4
  • 3
42
votes
2 answers

PHP: when to use arrays, and when to use objects for mostly-data-storing code constructs?

PHP is a mixed paradigm language, allowing to use and return non-object data types, such as arrays. I pose a question to try to clarify some guidelines for selection of arrays vs objects when deciding upon what programming construct to use in a…
Dennis
  • 8,157
  • 5
  • 36
  • 68
1
2 3
99 100