php

CakePHP - How do i set the page title to an item name?

OK, so I'm trying to teach myself the CakePHP framework, and I'm trying to knock up a simple demo app for myself. I have the controllers, views and models all set up and working, but I want to do something slightly more than the basic online help shows. I have a guitars_controller.php file as follows... <?php class GuitarsController e...

Using Javascript to perform a process and send updates/callbacks to a webserver.

I am working on a process to allow people to upload PDF files and manage the document (page order) via a web based interface. The pages of the PDF file need to be cropped to a particular size for printing and currently we run them through a Photoshop action that takes care of this. What I want to do is upload the PDF files to a dedicat...

Does PHP have a DEBUG symbol that can be used in code?

Languages like C and even C# (which technically doesn't have a preprocessor) allow you to write code like: #DEFINE DEBUG ... string returnedStr = this.SomeFoo(); #if DEBUG Debug.WriteLine("returned string =" + returnedStr); #endif This is something I like to use in my code as a form of scaffolding, and I'm wondering if PHP has so...

Screen Grab with PHP and/or Javascript?

Just wondering if it's possible to screen grab a page you are viewing with a PHP script or javascript? For example, load up a page in an iframe and then save that view as a JPEG? I'm sure it's possible somehow, but are there any known implementations/libraries that help out? ...

Getting file name of file directed by .htaccess?

Hello. I'm making a dynamic image for a forum that doesn't allow dynamic images. I tried using .htacess to redirect all *.png files to image.png... which works perfectly, but from here I can't seem to be able to get the filename of the .png that was requested to generate the content. is there a way to do this? For example... user ...

How do you make php's json_decode compatible with firefox's javascript?

it appears if you have something like var my_var = {"foo" : "bar"}; in javascript (with firefox at least) and post it to a php server you will receive a string like {foo:"bar",} on the server side. But json_decode in php doesn't like the trailing ',' or the lack or quotes around 'foo'. Is there a nice way to clean up the received...

PHP DOM: rather newbie question

I've just started tinkering with XML manipulation with PHP, and i've stumbled into something unexpected. Here's the XML i'm using as a test input: <list> <activity1> running </activity1> <activity2> swimming </activity2> <activity3> soccer </activity3> </list> Now, i was expecting that this PHP code would output 'activity1...

UTC Offset in PHP

What's the easiest way to get the UTC offset in PHP, relative to the current (system) timezone? ...

A Project Euler Puzzler (specifically in PHP)

There is another recent Project Euler question but I think this is a bit more specific (I'm only really interested in PHP based solutions) so I'm asking anyway. Question #5 tasks you with: "What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?" Now, I have solved it twice. Once very inefficiently and ...

PHP money string conversion to integer error

I have a small financial application with PHP as the front end and MySQL as the back end. I have ancient prejudices, and I store money values in MySQL as an integer of cents. My HTML forms allow input of dollar values, like "156.64" and I use PHP to convert that to cents and then I store the cents in the database. I have a function that...

XAMPP problems with PHP5

I enabled PHP5 on my website and my webhost needs me to add the following to .htaccess files for PHP5 to work: AddHandler application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml Locally, I am running XAMPP to develop code, but XAMPP does not want to work w...

What are best practices for developing consistent libraries?

I am working on developing a pair of libraries to work with a REST API. Because I need to be able to use the API in very different settings I'm currently planning to have a version in PHP (for web applications) and a second version in Python (for desktop applications, and long running processes). Are there any best practices to follow ...

How can I change a files extension using PHP?

How can I change a files extension using PHP? ...

Using function prototypes dynamically in PHP

Hi, I'm writing a construct in PHP where a parser determins which function to call dynamically, kind of like this: // The definition of what to call $function_call_spec = array( "prototype" => "myFunction", "parameters" => array( "first_par" => "Hello", ...

What is the best way to implement a petition? (email send after signing the petition)

I need to build a little webapp but I'm not sure what is the best thing to do. A person that subscribe the petition is signing an email sent to X. This will be also saved to a db in order to show online who subscribed. The idea is to have a standard text message, the user submit his name and that name goes into the message as signature...

How to deprecate a function in PHP?

At the team with which I work, we have an old codebase using PHP's ibase_* functions all over the code to communicate with database. We created a wrapper to it that would do something else beside just calling the original function and I did a mass search-replace in the entire code to make sure that wrapper is used instead. Now, how do w...

Delphi for PHP

I just came across Delphi for PHP and my immediate response was "oh, no", but I think maybe I was being too hasty. Has anyone tried it? What do you think? ...

Inserting data in XML file with PHP DOM

I was trying to insert new data into an existing XML file, but it's not working. Here's my xml file: <list> <activity>swimming</activity> <activity>running</activity> <list> Now, my idea was making two files: an index page, where it displays what's on the file and provides a field for inserting new elements, and a php page whi...

How to detect when a user has successfully finished downloading a file in php

I've got a php page which handles requets for file downloads. I need to be able to detect when a file has been downloaded successfully. How can this be done? Perhaps there's some means of detecting this client-side then sending a confirmation down to the server. Thanks. Edit: By handle, I mean that the page is doing something like this...

How do you write good PHP code without the use of a framework?

Other than standard OO concepts, what are some other strategies that allow for producing good, clean PHP code when a framework is not being used? ...