php

Selenium element not found

I am writing a Selenium test in PHP to check the performance of a web application in Firefox. I want to use this as a base-line for comparing different performance enhancements (upgrading JQuery, PHP 5.3, etc.). The web application is very AJAX intense and so far I have only run into one problem. I have an AJAX call that loads content...

formating data in php

What I need to be able do is format data in a variable, like so: format: xxx-xxx variable: 123456 output: 123-456 The problem is I need to be able to change the format, so a static solution wouldn't work. I also like to be able to change the variable size, like: format: xxx-xxx variable: 1234 output: 1-234 All ideas are welcome! Th...

PHP arrays: extract one dimension

I have an array that looks like: $fields = array( "f1" => array("test"), "f2" => array("other" => "values") ); I'd like to retrive this information in one array: $first_dimension = array("f1","f2"); Is there a function in PHP that can extract a particular dimension of an array directly? Is there a syntax shortcut for this? ...

PHP: Getting array type

Is there a php function that someone can use to automatically detect if an array is an associative or not, apart from explictly checking the array keys? ...

php static function

Hi, I have a question regarding static function in php. let's assume that I have a class class test { public function sayHi() { echo 'hi'; } } if I do test::sayHi(); it works without a problem. class test { public static function sayHi() { echo 'hi'; } } test::sayHi(); works as well. what are diff...

PHP equivalent to ASP.NET / SharePoint Webparts?

Is there a PHP equivalent to Webparts? I'm looking for an alternative to the user-pluggable, connectable, customisable application building blocks that are part of SharePoint. ...

How can I open a new browser tab in Eclipse PDT?

When I run a PHP script in Eclipse environment, I can select different browsers to render my page and can get different results. But the results are still all shown in the browser output window in eclipse itself. How can I prompt eclipse to actually open a new tab in the browser itself with the php page. I know it can be done by "exter...

How to display a date as iso 8601 format with PHP

I'm trying to display a datetime from my MySQL database as an iso 8601 formated string with PHP but it's coming out wrong. 17 Oct 2008 is coming out as: 1969-12-31T18:33:28-06:00 which is clearly not correct (the year should be 2008 not 1969) This is the code I'm using: <?= date("c", $post[3]) ?> $post[3] is the datetime (CURRENT_TI...

PHP Regex Difficulty

I am having difficulty doing regular expressions when there is whitespace and carriage returns in between the text. For example in this case below, how can I get the regular expression to get "<div id="contentleft">"? <div id="content"> <div id="contentleft"> <SCRIPT language=JavaScript> I tried id="content">(.*?)<SCRIPT but...

General php function for multiple forms

I have a small application in which i have 9 different forms, and every form have a least 40+ fields where the user must enter some data. I have written each form in a single php file and made a master PHP file where i only add the form in the middle of the page. My question is: I don't want to write 9 different function for each form...

SimpleTest Mocking Problem

I'm writing some test cases, and I've got a test case that is using Mock objects. I need to check to see if two class methods are called from another class method. Here's what I've done: First I generated the Mock: Mock::generate('Parser'); Then, inside my test I called: $P = new MockParser(); $P->expectOnce('loadUrl', array('http:...

How do I trigger a Javascript function AFTER the page loads?

** EDIT ** I'm afraid I wasn't in the right direction - the problem isn't what I asked about. the Javascript works as it should, it's the PHP that doesn't show what I want it to on the first "run" - and I'm stil not sure why. Sorry for somewhat wasting your time... ** I have a form that might or might not already contain data in its f...

How can I allow a download to pause/resume?

Normally, when I want to allow a user to download a file without revealing the exact location, I just use something like this to let them download the file: header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/octet-stream"); header("Conten...

does FastCGI work well with PHP?

does FastCGI work well with PHP? It seems that some people running Ruby on Rails have problems with FastCGI, but is it fine with PHP? ...

retrieve window.location.hash url in php

I am using a jquery tabbed interface here http://www.imashdigital.com/#2 and would like to return the tab number in php. Ideally I would like to run a javascript function (on a timer) that continually updates a global php variable with the current tab. Based on this php value, 1 through to 4, I will then load a different sidebar. I wo...

Why does livehttpheaders show my login and password and how can I prevent it?

I was looking at the livehttpheaders plugin for Firefox and decided to test my login page. I noticed that the parameters shown inside of it contain my login and password. For example: username=sarmenhb&password=thepassword&submit=Login in plain English. I don not see this on other sites. What can I be doing wrong? I see this as a se...

PHP - Output Firefox JSON data

Is it possible to output specific JSON data (exported from Firefox bookmarks) using PHP. This is the code which I have so far, it will re-encode the data as Firefox doesn't export it in the correct UTF-8 way. I also remove the trailing , from the end of the file. <?php // Read the file blah blah $hFile = "../uploads/james.json"; $hFile...

Where is a good guide for Drupal themeing?

I'm new to Drupal, and frankly after reading through the Drupal documentation, their guide to themeing isn't all that helpful. Maybe I'm just misunderstanding, but it seems like there are certain variables you always have access to and different functions you can define to override or implement behavior. Long story short, I'd like to b...

using variable in mysql_fetch_assoc to output data from a column in a multi row.?

if i have a query like this $query = mysql_query(" SELECT * FROM tbl_school INNER JOIN tbl_livingexp ON (tbl_school.schoolname=tbl_livingexp.schoolname) INNER JOIN tbl_tuition ON (tbl_school.schoolname=tbl_tuition.schoolname) INNER JOIN tbl_apprequirments ON (tbl_school.schoolname=tbl_apprequirments.schoolname) where tbl_school.school...

Sort arrays into multidimensional array by key

I have a database table which gives me the following result: array(8) { ["link_id"]=> string(2) "20" ["link_url"]=> string(56) "http://url.of/website" ["link_name"]=> string(34) "Website title" ["link_target"]=> string(0) "" ["link_description"]=> string(0) "" ["link_updated"]=> string(19)...