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

learn more… | top users | synonyms

10
votes
4answers
1k views

When should I use mock objects?

I've read a lot of things about TDD but I still have doubts. For example, I have these class diagrams: It's a simple example, just to learn about TDD and mock objects. Which test should I write ...
12
votes
3answers
3k views

what are the best tips for storing images in a database?

Is it appropriate to store the image files in the database? Or it would be better to store only the path of the file in the database, while keeping the file itself on the server? Are there any other ...
14
votes
9answers
12k views

When do I need to use a framework? [closed]

I am new to web programming and at this time I am learning about PHP. I would like to know when do I need to use a PHP framework such as CakePHP? What are things that this and other similar PHP ...
26
votes
5answers
12k views

What best practices should be employed in a PHP login script?

I am wanting to re-write my login scripts for clients websites to make them more secure. I want to know what best practices I can implement into this. Password protected control panels are in their ...
37
votes
7answers
26k views

Why is Zend Framework so complicated?

I am web developer and have experience of developing several web applications in PHP. I have an idea of developing a product for myself and decided to use a MVC based framework because I really like ...
24
votes
3answers
9k views

I'm trying to understand hash tables - can someone explain it to me - clearly?

I want to understand the correct use and implementation of hash tables in php (sorry). I read somewhere that an in-experienced programmer created a hash table and then iterated through it. Now, I ...
22
votes
6answers
9k views

Why is using 'final' on a class really so bad?

I am refactoring a PHP OOP legacy website. I am so tempted to start using 'final' on classes to "make it explicit that the class is currently not extended by anything". This might save lots of time ...
1
vote
4answers
2k views

Is it bad to learn multiple programming languages? [closed]

I started learning PHP and I was able to get myself familiar with it. Now, I want to explore other programming languages like PERL so that I can compare it myself to PHP. Will I be confused to learn ...
48
votes
4answers
90k views

How can I test PHP skills in a interview? [closed]

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 ...
36
votes
6answers
31k views

Naming classes, methods, functions and variables [duplicate]

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 ...
109
votes
7answers
8k views

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? [closed]

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 ...
46
votes
13answers
13k views

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 : <script type="text/javascript"> $(document).ready(function(){ $('<?php echo $divID ?>').click(funtion(){ ...
27
votes
3answers
14k views

How to build completely modular web applications [closed]

In the coming months we're going to begin a project where we take a system we've built for a client (v1) and rebuild it from scratch. Our goal with v2 is to make it modular, so that this specific ...
18
votes
8answers
3k views

What would you consider best practice workflow tools for web application (PHP) development? [closed]

I'm really hoping somebody with more experience can edit the question as per my examples of answers: using version control test driven development debugging code (xdebug for php) use of UML diagrams ...
26
votes
4answers
33k views

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

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, ...
5
votes
5answers
1k views

Which open-source license is right for my project?

I am trying to choose the right license for a project that I would like to release as open-source later this year but I am unsure as to what the most appropriate license would be. I was originally ...
10
votes
4answers
3k views

In MVC, can/should basic data retrieval from the Model be done in the View?

Given the concept of 'skinny controllers, fat models' and the general acceptance that Views can directly call on Models when requiring data for output, should one consider handling the 'get and ...
6
votes
2answers
11k views

What is the best way to create REST API error response model and error codes system?

My REST implementation will return errors in JSON with next structure: { "http_response":400, "dev_message":"There is a problem", "message_for_user":"Bad request", "some_internal_error_code":...
16
votes
7answers
4k views

Is it possible to effectively develop PHP applications on Windows that will be deployed on servers running Linux?

Is it fine to code PHP on Windows and host it later on a server running Linux? Can there be any problems in the migration of such a project? I would think that there really can't be any problems, ...
6
votes
4answers
2k views

When is it necessary to use ORM tools? [closed]

I was raised in a part of web developmentland where the creation of websites is mostly synonymous with Wordpress, FTP, Joomla, and procedural code, instead of things like TDD, A/B testing, Doctrine, ...
14
votes
2answers
2k views

Illegal in PHP: Is there an OOP design reason?

The below interface inheritance is illegal in PHP, but I think it would be fairly useful in real life. Is there an actual antipattern or documented problem with the below design, that PHP is ...
3
votes
3answers
3k views

OO PHP static keyword, should I use it?

I'm writing script for fb and I have 3 objects that I'll be using through all classes. I'm wondering if there is any advantage in using the static keyword except I don't have to create an instance ...
10
votes
9answers
2k views

My university doesn't provide php courses because it is an “easy” programming language? [closed]

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 ...
6
votes
1answer
403 views

General approach to re-factoring an large, very badly written legacy system [duplicate]

Possible Duplicate: Techniques to re-factor garbage and maintain sanity? What is a good way to refactor a large, terribly written code base by myself? Really open question here. I'm not ...
3
votes
4answers
3k views

PHP, structural or OOP based language? [closed]

I would like to discuss why is PHP called a structural language? what are the OO concepts that cannot be implemented using PHP?
3
votes
9answers
15k views

Is there a way to develop desktop software using PHP?

I have to develop a real estate marketing CRM software for my client - where the application is installed on desktop but can also be accessed from web. 2 reasons why they want the application to run ...
3
votes
2answers
946 views

Why do ruby and python seem to have more community contribution than PHP? [closed]

In a recent blog post by Roy Osherove, it is pointed out that his switch from primarily .Net development to ruby development has seen a huge difference in community involvement and really enjoys it. ...
15
votes
1answer
1k views

Dollar Sign Blues: Javascript and PHP

I grew up programming C++ and Java where everything was safe and beautiful. Compilers made sure to keep me in check if I ever strayed. Of course, everyone did a little Perl in college, but I didn't ...
11
votes
4answers
761 views

Is it OK to introduce methods that are used only during unit tests?

Recently I was TDDing a factory method. The method was to create either a plain object, or an object wrapped in a decorator. The decorated object could be of one of several types all extending ...
4
votes
4answers
2k views

Best Method of function parameter validation

I've been dabbling with the idea of creating my own CMS for the experience and because it would be fun to run my website off my own code base. One of the decisions I keep coming back to is how best ...
3
votes
6answers
1k views

When to use a API/Library and when to write your own?

I am working on a large website and having been thinking a lot about when I should be using a 3rd party API/Library and when I should be writing my own implementation from scratch. There is no Library ...
11
votes
5answers
2k views

Advantages to Multiple Methods over Switch

I received a code review from a senior developer today asking "By the way, what is your objection to dispatching functions by way of a switch statement?" I have read in many places about how pumping ...
3
votes
1answer
158 views

What are possible/useful implementations when extending exceptions?

I have seen a lot of exceptions - custom or integrated in the language (PHP) itself that have no differences but their class name. When extending default exceptions to use within your own code, are ...
3
votes
2answers
453 views

Is having sensitive data in a PHP script secure?

I've heard that PHP is somewhat secure because Apache won't allow the download of raw PHP. Is this reliable, though? For example, if you wanted to password protect something, but didn't want to create ...
1
vote
3answers
302 views

Using static in PHP

I have a few functions in PHP that read data from functions in a class readUsername(int userId){ $reader = getReader(); return $reader->getname(userId); } readUserAddress(){ $reader = getReader();...
0
votes
2answers
176 views

Integration Tests - How much is too much? [duplicate]

First of I'm not sure if I chose the right name for my question, I'm not sure if they are functional tests or integration ( or other ). I'm talking about tests which test (or it should) the app from ...
34
votes
13answers
30k views

Career advice: stay with PHP or start a new career in something else ( .Net?) [closed]

I'm planning on moving to NY in 6-12 months tops, so I'm forced to find a new job. When I'm planing to start my life in another city it's also probably a good time to think about career changes. I've ...
16
votes
3answers
19k views

PHP web application architecture/design [closed]

I've been thrown head-first into a new job developing web applications in PHP. I'm by no means new to PHP, but I haven't developed large-scale applications before. I'm wondering how to structure my ...
22
votes
1answer
16k views

With PHP frameworks, why is the “route” concept used?

The reason I ask this is because isn't a PHP script a route? For example, if you have an article.php then your route is simply http://mysite.com/article.php. Why further abstract away the concept of ...
35
votes
7answers
49k views

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 ...
23
votes
9answers
11k views

Should I build my own CMS or rely on a pre-built one? [closed]

Related: As a beginning programmer, should I favor building my own libraries over using 3rd-party libraries? As an intermediate to advanced level PHP web-developer and a young one at that (15yrs.), ...
15
votes
4answers
26k views

REST vs RESTful vs “normal” web service - the same or not?

I've read a couple of definitions and discussion on REST and/or RESTful applications, but I still do not understand the real meaning of it. I usually work with the apps which either fetch data via ...
4
votes
1answer
278 views

Pointers to implementing a taxonomy system?

I am taking part in the development of a PHP CMS (yeah I know you are like, meeh). It is currently using simple tags for tagging content. What I want to do is push the whole thing to using Taxonomy ...
36
votes
11answers
3k views

Why isn't protection against SQL injection a high priority?

On Stack Overflow, I see a lot of PHP code in questions and answers that have MySQL queries that are highly vulnerable to SQL injection attacks, despite basic workarounds being widely available for ...
13
votes
3answers
2k views

What is the best way to do offline failover of a desktop based client that uses a web service?

I have three incoming projects that share a common problem: they need to have the logic on a web system and they need a local application (e.g. point of sale) that communicates with such system ...
12
votes
7answers
4k views

How much does a web developer need to know about Linux? [closed]

I was just wondering if a typical PHP developers needs to be very familiar with Linux. I am studying Linux right now and I believe some of linux knowledge is not required for a PHP developer job (not ...
10
votes
2answers
787 views

What is a good way to familiarize myself with PHP, coming from an ASP.NET background? [closed]

Currently, I'm very comfortable with building tools/web apps in an ASP.NET environment. I'm not really looking to leave tbh, as I really like C#, ASP.NET, MVC 3, Visual Studio, etc. However, right ...
7
votes
3answers
1k views

Integrating with a payment provider; Proper and robust OOP approach

History We are currently using a so called redirect model for our online payments (where you send the payer to a payment gateway, where he inputs his payment details - the gateway will then return ...
11
votes
3answers
5k views

Is the term 'Front-End' synonymous with 'Client-Side'? If so, is this always the case?

As a relatively new (self-taught) web developer, I've heard the terms front-end, client-side, back-end, and server-side quite often. To me, front-end and back-end were always synonymous with client-...
8
votes
5answers
3k views

Most MVC-strict php framework [closed]

I have been trying to wrap my head around MVC pattern for about 6 months.I've read tons of articles, Q&A, and blog posts about MVC and HMVC patterns, but I just simply don't get it 100%. I tried ...