Skip to content

Tag: php

How well does FFmpeg scale? Any examples?

I’m currently working on the server side of an augmented reality project. It’s a lot like http://www.livingsasquatch.com/. I’m using PHP/MySQL and FFmpeg to capture the webcam video and encoding it to .flv. Basically Flash uploads the video as a long series of .jpg images. PHP then takes tho…

Undefined index: Error in php script

In a php page I have following code: I keep getting Undefined index error. On Googling I manage to understand that if a page is access without parameters (in URL) which we are trying to access we can get this error/warning. I believe that if a parameter is not defined in the URL it should just return empty in…

Loop through all months in a date range?

If I have a start date (say 2009-02-01) and an end date (say 2010-01-01), how can I create a loop to go through all the dates (months) in the range? Answer Try Mind the note http://php.net/manual/de/datetime.formats.relative.php Relative month values are calculated based on the length of months that they pass…

What’s wrong with using $_REQUEST[]?

I’ve seen a number of posts on here saying not to use the $_REQUEST variable. I usually don’t, but sometimes it’s convenient. What’s wrong with it? Answer There’s absolutely nothing wrong with taking input from both $_GET and $_POST in a combined way. In fact that’s what yo…

How to gracefully handle files that exceed PHP’s `post_max_size`?

I’m working on a PHP form that attaches a file to an email, and trying to gracefully handle cases where the uploaded file is too large. I’ve learned that there are two settings in php.ini that affect the maxiumum size of a file upload: upload_max_filesize and post_max_size. If a file’s size …

Convert large XML file to CSV in PHP

I have a 50MB XML file. I want to convert it to a CSV file, but most methods I have found exhaust the server memory. Is there a good way to do this using a stream method such as XMLreader. Answer You’d want to use XmlReader to parse the XML, as it works as an event based parser – Eg.

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…