Quantcast
Channel: When to use a Class vs. Function in PHP - Stack Overflow
Viewing all articles
Browse latest Browse all 7

When to use a Class vs. Function in PHP

0
0

The lightbulb has yet to go on for this...

I'd really love an easy to understand explanation of the advantage to using a class in php over just using functions.

Here's a simple example of the thought I'm having now and am wondering if a class is more efficient:

Say I have a mini calendar widget that I've built in php. I'm thinking about calling the function miniCal('arrayVars1', 'var2'). But I might do it twice on that page. Do use fewer resources by using a class here, create new instances of it?

What tree should I be barking up here, because I feel like right now the tree is a brick wall...


Viewing all articles
Browse latest Browse all 7

Latest Images

Trending Articles





Latest Images