What code do you need to add in PHP to automatically have the browser download a file to the local machine when a link is visited?
I am specifically thinking of functionality similar to that of download sites that prompt the user to save a file to disk once you click on the name of the software?
...
A little background:
I've been looking at a few php framework recently and it came down to 2 framework. The zend framework or Code Igniter.
I prefer CI because if it's simple design. It's very barebone and just kept it simple. But the thing I didn't like is the weak template system. The template system is important for me because I wil...
I'm trying to write a page that calls PHP that's stored in a MySQL database. The page that is stored in the MySQL database contains PHP (and HTML) code which I want to run on page load.
How could I go about doing this?
...
I am planning on creating a small website for my personal book collection. To automate the process a little bit, I would like to create the following functionality:
The website will ask me for the ISBN number of the book and will then automatically fetch the title and add it to my database.
Although I am mainly interested in doing this...
When using the php include function the include is succesfully executed, but it is also outputting a char before the output of the include is outputted, the char is of hex value 3F and I have no idea where it is coming from, although it seems to happen with every include.
At first I thbought it was file encoding, but this doesn't seem ...
I have tried both
ini_set('include_path', '.:/usr/share/php5:/usr/share/php5/PEAR:lib:app/classes');
in the code itself and also
php_value include_path ".:/usr/share/php5:/usr/share/php5/PEAR:lib:app/classes"
in the .htaccess file.
Both methods actually do work but only intermittently. That is, they will work fine for about 37 pa...
I'm working on a project that I'd eventually like to package as a reusable PHP library. Can anyone suggest some best practices for doing so? Directory structure? File naming conventions? Anything else I might not be thinking of? Or should I just put everything in an appropriately named .php file or two and call it good? Thanks.
...
Why does the following code not work as I was expecting?
<?php
$data = array(
array('Area1', null, null),
array(null, 'Section1', null),
array(null, null, 'Location1'),
array('Area2', null, null),
array(null, 'Section2', null),
array(null, null, 'Location2')
);
$root = array();
foreach ($data as $row) {
if ($...
I know that I can do something like
$int = (int)99; //(int) has a maximum or 99
To set the variable $int to an integer and give it a value of 99, Is there a way to set the type to something like LongBlob in MySQL for LARGE Integers in PHP?
...
What I have so far is
#!/bin/sh
php_syntax_check()
{
retval=0
for i in $(git-diff-index --name-only --cached HEAD -- | grep -e '\.php$'); do
if [ -f $i ]; then
output=$(php -l $i)
retval=$?
if [ $retval -gt 0 ]; then
echo "===========================================================================...
I need to get the first and last day of a month in the format YYYY-MM-DD given only the month and year. Is there a good, easy way to do this?
...
This is a php example, but an algorithm for any language would do. What I specifically want to do is bubble up the United States and Canada to the top of the list. Here is an example of the array shortened for brevity.
array(
0 => '-- SELECT --',
1 => 'Afghanistan',
2 => 'Albania',
3 => 'Algeria',
4 => 'American Samoa',
5 =...
For years, I've been investigating how to create music streams from my computer. I've seen programs, but anything useful I've seen is windows only (I use a Mac).
Eventually, I got interested in how streams work. Is there any way I could create my own stream, possibly using socket functions in PHP? Is there a PHP library for this?
Th...
My team is currently trying to automate the deployment of our .Net and PHP web applications. We want to streamline deployments, and to avoid the hassle and many of the headaches caused by doing it manually.
We require a solution that will enable us to:
Compile the application
Version the application with the SVN version number
Backu...
I need to execute a directory copy upon a user action, but the directories are quite large, so I would like to be able to perform such an action without the user being aware of the time it takes for the copy to complete.
Any suggestions would be much appreciated.
...
I have a php server that is running my domain name. For testing purposes I am running an asp.net on a dotted quad IP. I am hoping to link them together via either php or some kind of dns/htaccess voodoo.
So if I go to www.mydomain.com/test it redirects (but keeps the url of (www.mydomain.com/test) in the main bar or awesome bar or wh...
I am a web-developer working in PHP. I have some limited experience with using Test Driven Development in C# desktop applications. In that case we used nUnit for the unit testing framework.
I would like to start using TDD in new projects but I'm really not sure where to begin.
What recommendations do you have for a PHP-based unit test...
I am writing a webapp using CodeIgniter that requires authentication. I created a model which handles all my authentication. However, I can't find a way to access this authentication model from inside another model.
Is there a way to access a model from inside another model?
or
Is there a better way to handle authentication inside Cod...
Does anyone know of a library (preferably php) or algorithm for auto-generating regex's from some common descriptions?
For example, have a form with the possible options of:
Length (=x, between x & y, etc)
Starts with
Ends with
Character(s) x(yz) at index i
Specify one or more alternative behavior based on the above
And so on..
The ...
What are the differences between htmlspecialchars and htmlentities. When should I use one or the other?
...