Skip to content
Advertisement

Tag: php

What is the function __construct used for?

I have been noticing __construct a lot with classes. I did a little reading and surfing the web, but I couldn’t find an explanation I could understand. I am just beginning with OOP. I was wondering if someone could give me a general idea of what it is, and then a simple example of how it is used with PHP?

Convert a String to Variable

I’ve got a multidimensional associative array which includes an elements like I’ve got a strings like: How can I convert the strings into a variable to access the proper array element? This method will need to work across any array at any of the dimensions. Answer Quick and dirty: Of course the input string would need to be be sanitized

Serving large files with PHP

So I am trying to serve large files via a PHP script, they are not in a web accessible directory, so this is the best way I can figure to provide access to them. The only way I could think of off the …

$_POST vs. $_SERVER[‘REQUEST_METHOD’] == ‘POST’

Some guy called one of my Snipplr submissions “crap” because I used if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’) instead of if ($_POST) Checking the request method seems more correct to me because that’s what I really want to do. Is there some operational difference between the two or is this just a code clarity issue? Answer Well, they don’t do the same

HTTP Headers for File Downloads

I’ve written a PHP script that handles file downloads, determining which file is being requested and setting the proper HTTP headers to trigger the browser to actually download the file (rather than displaying it in the browser). I now have a problem where some users have reported certain files being identified incorrectly (so regardless of extension, the browser will consider

How to make PDF file downloadable in HTML link?

I am giving link of a pdf file on my web page for download, like below The problem is when user clicks on this link then If the user have installed Adobe Acrobat, then it opens the file in the same browser window in Adobe Reader. If the Adobe Acrobat is not installed then it pop-up to the user for

Advertisement