Short Tag – Web Development Blog

Entries for the ‘PHP with other technologies’ Category

How to disable XDebug

If you want to disable XDebug on your server for some reason, you can do one of the following:
1.) Locate your php.ini file (the server’s php.ini or if your server allows it create one in the root of your website). Find the following directives and change them as below:

xdebug.remote_autostart=0
xdebug.remote_enable=0
xdebug.profiler_enable=0

2.) Disable it just for one website [...]

PHP MIME E-mail decoding with PEAR’s MimeDecode

In my previous article “PHP e-mail PIPE, cPanel PIPE forwarding” I was explaining how you can create an e-mail PIPE and get the e-mail with PHP.
This is the code you should use to get the email from stdin:

// read from stdin
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);

Now, we have the content [...]

PHP e-mail PIPE, cPanel PIPE forwarding

E-mail PIPEs are e-mail forwarders that forward an email to an application and not an other email address. Recently I had to develop such a script so I thought I could share what I learned with you.
1.) Setting up the PIPE
Firstly you have to make sure your web hosting provider allows you to create E-mail [...]

CGI script and PHP

CGI it’s not a programming language. CGI(Common Gateway Interface) it’s just an interface between the http server and the software residing on the host machine.
You can write CGI script using a variety of programming languages: PHP, PERL, C, C++, etc.
Why use CGI scripts?
CGI scripts are very useful when you need to combine PHP with other [...]

Unzip with PHP

To unzip with PHP you need to have your PHP server compiled with php_zip.dll on Linux or the php_zip.dll extension active on Windows(activate it from php.ini).

$zip = zip_open("zip.zip");
//first we open the zip file, $zip is a file handler

if ($zip) {
while ($zip_entry = zip_read($zip)) {
//reading each zip entry (zip file)

$fp = fopen("zip/".zip_entry_name($zip_entry), "w");
//open the file for [...]

Get the domain of an e-mail address with PHP

function getEmailDomain($email)
{
$email = trim($email);
$emails = explode(@, $email);
return trim($emails[1]);
}

Connect to your POP3/IMAP mailbox with php and read e-mails

Thanks to PHP’s library this is a very easy thing to do.  We will use the imap_ functions (their names start with imap_).  Imap_ functions can also work with POP3 mailboxes (don’t get fooled by their names).
In order to get all your new emails from your mailbox you would use this code:

if (($emailbox = imap_open("{computername:110/pop3}INBOX", [...]

Creating PDF documents from HTML content via PHP

Since PDF is such a very frequently used file type every web developer will face the challenge of developing an application that creates a PDF file.
And this is indeed a challenge. There are a few classes out there for PHP, but you can’t find a perfect one, because every one of them has to render [...]