Skip to content

How to get instance of a specific class in PHP?

I need to check if there exists an instance of class_A ,and if there does exist, get that instance. How to do it in PHP? As always, I think a simple example is best. Now my problem has become: How to store the instance in a static member variable of class_A when instantiating? It’ll be better if the ins…

Formulas to Calculate Geo Proximity

I need to implement a Geo proximity search in my application but I’m very confused regarding the correct formula to use. After some searches in the Web and in StackOverflow I found that the solutions are: Use the Haversine Formula Use the Great-Circle Distance Formula Use a Spatial Search Engine in the …

Passing parameters to PHPUnit

I’m starting to write PHPUnit tests and I’d like the tests to be run from developers machines as well as from our servers. Developers machines are set up differently than the servers and even …

Download of .zip file runs a corrupted file php

I’m trying to force a download of a protected zip file (I don’t want people to access it without logging in first. I have the function created for the login and such , but I’m running into a problem where the downloaded file is corrupting. Here’s the code I have: Here’s the error…

Extract link attributes from string of HTML

What’s the best way to extract HTML out of $var? example of $var I want example: preg_match(); what else? Answer Instead of crafting long complicated regex, do it in steps one way of “non regex”, using explode