php

How to more effectively debug PHP code in the vein JavaScript with Firebug or XCode?

Hi everyone, I'm kind of a newbie with PHP so please bear with me. I would like to know if there was an effective way of debugging PHP code so that I don't have to have debugging messages display on the browser. For example, I find var_dump and print_r functions to be excellent for debugging variables, function calls and arrays respect...

how i got the name of the string variable in the strange attempt to debug unknown variable ?

i got several variable. One is variable string, object, and array. $mystring = "hello im input"; $myobject = new userclass; $myarray = array ( 0 => 'zero', 1 => "one"); i want to create a new array with its variable name as key before send it to as function parameter with it's first line use extract function. the multi_array will ...

Get mime type of external file using cURL and php

I've used mime_content_type() and File info but i never successed. i want to use now cURL with PHP and get the headers of the file which is hosted on another domain then extract & determine if the type is MP3 or not. ( i think the mime type of MP3 is audio/mpeg ) Briefly, i know that but i don't know how to apply it :) Thanks ...

What is a PHP library that will show inline diffs?

I'm looking for a PHP library that will provide me inline diffing between two strings, like this: http://grabby.info/dfe2835f606443757ae7c18404e71781.png. I'm using xdiff currently, but it's crossing out the entire line when a single word changes, and that's not what I want. Any suggestions? ...

Cancel key down, press, up event in PHP javascript, C#

I want to cancel out key press event when my textarea field gets n number of characters from user. At that point i dont want user to enter any more characters. What to do? Edit: I need it to be done in javascript as well as in php ...

What is the holdup on PHP 6?

I've read in multiple places, including highly recommended PHP books published several years ago, that PHP 6 was just over the horizon, and would fix several of the BIG outstanding issues with PHP (namely unicode support). However, its been several years even since I've read those books, and PHP 6 is still not considered kosher for produ...

PHP regex help -- reverse search?

So, I have a regex that searches for HTML tags and modifies them slightly. It's working great, but I need to do something special with the last closing HTML tag I find. Not sure of the best way to do this. I'm thinking some sort of reverse reg ex, but haven't found a way to do that. Here's my code so far: $html = '<div id="test"><p styl...

How do I make these fields autopopulate from the database?

I have an array, which holds values like this: $items_pool = Array ( [0] => Array ( [id] => 1 [quantity] => 1 ) [1] => Array ( [id] => 2 [quantity] => 1 ) [2] => Array ( [id] => 72 [quantity] => 6 ) [3] => Array ( [id] => 4 [quantity] => 1 ) [4] => Array ( [id] => 5 [quantity] => 1 ) [5] => Array ( [id] => 7 [quantity] => 1 ) [6] ...

WordPress > Activating plugin makes site go blank in one theme, not in another. Generated source identical

Strangest thing. When I activate this specific plugin, the public side of the site goes blank (nothing but a white screen with blank view source). However, when I test the site with the wordpress default theme, the plugin does not conflict and the site works fine. The interesting thing is that I've compared the generated source (using F...

Populating a Dropdown list in PHP dynamically

Hi, I have a small PHP page which contains two drop down lists I need to populate the second one according to the result selected in the first drop down list .... is this possible? In other words I need to use the value selected from the first drop down list and use it in the dB query used to populate the second drop down list (but th...

How do I access data within this multidimensional array?

I have this array: $items_pool = Array ( [0] => Array ( [id] => 1 [quantity] => 1 ) [1] => Array ( [id] => 2 [quantity] => 1 ) [2] => Array ( [id] => 72 [quantity] => 6 ) [3] => Array ( [id] => 4 [quantity] => 1 ) [4] => Array ( [id] => 5 [quantity] => 1 ) [5] => Array ( [id] => 7 [quantity] => 1 ) [6] => Array ( [id] => 8 [quanti...

Dedicated podcast for PHP beginners

I'm looking for any PHP/programming podcast episodes which specifically talk about PHP classes and objects. Maybe this is too specific but any reference is ok. BTW, are there any dedicated podcasts for PHP beginners? ...

Parsing Twitter API Datestamp

I'm using the twitter API to return a list of status updates and the times they were created. It's returning the creation date in the following format: Fri Apr 09 12:53:54 +0000 2010 What's the simplest way (with PHP or Javascript) to format this like 09-04-2010? ...

How can I specify how many levels deep the timespan() function in Codeigniter should go?

I'm using Codeigniter's "timespan()" function to give a human readable phrase of how much time has elapsed since an event: "5 days, 3 hours, 12 minutes, 1 second", but I don't need to go down to the minute or second level. Is there any way to turn that off? ...

Doctrine lazy loading classes takes 100 ms?!

I'm lazy loading my Doctrine classes in my website. Benchmarking has showed that Doctrine::loadModels('models') takes over 100 ms to complete! I have 118 tables in total, but still... setting attribute to conservative loading: Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATI...

Firefox fails to detect content type set by PHP

Hi all, I want a php page to 'display' a pdf. Here is the code: <?php header("Content-type: application/pdf"); readfile('Reportage - Berlin.pdf'); //tried echo(readfile(...)) as well ?> Not very complicated I think, but somehow firefox cant detect that this is a pdf. This works in Safari but in firefox, i get a prompt to download...

What does the C++ output of the HipHop PHP compiler look like?

Is it clean enough that you can discard the PHP and hand-optimize the C++ code? ...

Correctly include php header in all pages

I would include a php header (mysite.com/header.php) in all the pages from a site. How to do it properly? There are relative links: <?php include_once 'header.php'; ?> <?php include_once '../header.php'; ?> And this didn't help: <?php include_once '/header.php'; ?> ...

Why is an inverse loop faster than a normal loop (test included)

I have been running some small tests in PHP on loops. I do not know if my method is good. I have found that a inverse loop is faster than a normal loop. I have also found that a while-loop is faster than a for-loop. Setup <?php $counter = 10000000; $w=0;$x=0;$y=0;$z=0; $wstart=0;$xstart=0;$ystart=0;$zstart=0; $wend=0;$xend=0;$y...

reverse geocode a set of co-ordinates

I have sets of co-ordinates in the following format (-33.9,18.6) How do I go about getting the name of the nearest town or Country for those co-ords? I'm guessing it will involve Javascript, but am happy to also use PHP if appropriate? EDIT: Am trying the Google Reverse Geocoder but having trouble with it. The following code is p...