Skip to content

Tag: php

PHP: how can I get file creation date?

I am reading a folder with lots of files. How can I get the creation date of a file. I don’t see any direct function to get it. There are filemtime and filectime. And if the file hasn’t been modified, what will happen? Answer Use filectime. For Windows it will return the creation time, and for Uni…

control file to PHP array

In Linux, .DEB files have ‘control’ text files that are arranged as follows: What is the best way to get the control file into a PHP array resembling: keeping in mind that the values can be multi-line and include the “:” separator. Thanks! Answer Implemented as described here: http://w…

Convert this array to an HTML List

I have this array: OR Every key is the id and value is the id for the childs of this parent. ID of 0 means that (3 & 6) have no parent. Now, i want to output an HTML list like: 3 4 7 8 9 5 6 Answer Test it. or

PHP PDO: charset, set names?

I had this previously in my normal mysql_* connection: Do I need it for the PDO? And where should I have it? Answer You’ll have it in your connection string like: HOWEVER, prior to PHP 5.3.6, the charset option was ignored. If you’re running an older version of PHP, you must do it like this:

Email PDF Attachment with PHP Using FPDF

I want to email a PDF as an attachment that was created using FPDF. My code looks like this, but the attachment never comes through. Anyone familiar with doing this? I’m hoping to use the PHP mail() function. Answer This ended up working for me:

Setting up scripting and mysql database on separate servers

I have a unique setup for a web application that I need to get my head around. I have two servers that will need to talk to each other. Server A will host the actual PHP-based application; Server B will host the MySQL database and the server connection details. Server B will also be within a closed network, s…

PHP input sanitizer function?

What’s a method to sanitize PHP POST data for passing to a mail function? (I prefer a method that’s not part of the mysql_function() family of functions.) I take the data, sanitize it, print it back to the user and send it in an email to a preset address. EDIT: I’m just sending the email to …