php

which unit-test framework for PHP: simpletest, phpunit or ?

I'm a big fan of simpletest because it's what I know. It has excellent support for mocking and web-testing. But I'm always scared of stagnating so any compelling arguments to switch would be appreciated. ...

Format text in Excel file via PHP

Hi, I'm loading data from my database, and exporting to an Excel file via a method I found on this site: http://www.appservnetwork.com/modules.php?name=News&file=article&sid=8 It works, but what I want to do now is format the text before it exports - change the font and text size. Does anybody have any ideas on how to do this? ...

XDebug server on Eclipse PDT test server issue

I have Eclipse PDT with Subclipse installed and currently have a PHP project drawing from a repository on my production server. I have VMWare Workstation installed with Linux and was hoping to use that as a debug server using XDebug. The problem is that when I update files, they are only committed to the repository on my production ser...

PHP_SELF vs PATH_INFO vs SCRIPT_NAME vs REQUEST_URI

Hi All, I am building a PHP app in CodeIgniter. CI sends all requests to the main controller, /index.php. However, I don't like to see the index.php in the URL, so I've used mod_rewrite, as per the CI documentation. The rule is as follows: RewriteEngine on RewriteCond $1 !^(images|inc|favicon\.ico|index\.php|robots\.txt) RewriteRu...

How to get the FTP error when using PHP

I have a script which logs on to a remote server and tries to rename files, using PHP. The code currently looks something like this example from the php.net website: if (ftp_rename($conn_id, $old_file, $new_file)) { echo "successfully renamed $old_file to $new_file\n"; } else { echo "There was a problem while renaming $old_file to $n...

php quotation strip

In my webpage, I want the website to greet the user, but the username is surrounded by 'single quotations'. Since this isn't to prevent MySQL injection, i just want to remove quotes around my name on the display page. Ex: Welcome 'user'! I'm trying to find the way where i can strip the quotations around the user and have it display on t...

PHP by-reference parameters and default null

Let's say we have a method signature like public static function explodeDn($dn, array &$keys = null, array &$vals = null, $caseFold = self::ATTR_CASEFOLD_NONE) we can easily call the method by omitting all parameters after $dn: $dn=Zend_Ldap_Dn::explodeDn('CN=Alice Baker,CN=Users,DC=example,DC=com'); We can also call the metho...

Persistent database connections in fastcgi

I'm porting an application from php to fastcgi (c). My host runs apache. Since the fastcgi app would be running in a loop, I could open a mysql connection, and leave it open for all incoming requests. Is this recommended? I think I've read about an equal number of opinions saying the connection is way more expensive than the request an...

Can I detect animated gifs using php and gd?

Hi all, I'm currently running into some issues resizing images using GD. Everything works fine until i want to resize an animated gif, which delivers the first frame on a black background. I've tried using getimagesize but that only gives me dimensions and nothing to distinguish between just any gif and an animated one. Actual resizi...

Random image picker PHP

$images = array(); $images[0][0] = "boxes/blue.jpg"; $images[0][1] = "blah.html"; $images[1][0] = "boxes/green.jpg"; $images[1][1] = "blah.html"; $images[2][0] = "boxes/orange.jpg"; $images[2][1] = "blah.html"; $images[3][0] = "boxes/pink.jpg"; $images[3][1] = "blah.html"; $images[4][0] = "boxes/purple.jpg"; $images[4][1] = "blah.html"; ...

changing tables rows to links

Hello, I am trying to change the rows output by php in a table to links. I have added the a href tags to the example below, however it results in an unexpected T_VARIABLE. I have tried it without the extra quotes, but this displays a blank table. I am not sure what the flaw in the logic is. while($row = mysql_fetch_row($result)) { e...

Is there a way to bind an array to mysqli prepare

I'm trying to make a class that will execute any one of a number of stored procedures with any amount of variables Im using php and mysqli My class enumerates an array and constructs a string based on the number of elements if any giving something like this CALL spTestLogin(?,?) for example I now need to bind the input from my array u...

Weighted Mean

I have an existing web app that allows users to "rate" items based on their difficulty. (0 through 15). Currently, I'm simply taking the average of each user's opinion and presenting the average straight from MySQL. However, it's becoming clear to me (and my users) that weighting the numbers would be more appropriate. Oddly enough, a...

I want the simplest ajax form application

I want ajax application to process a simple form with textinput and submit button only , and without validation , i want to add this with a php script . I ask this because i don't know how to program with ajax or javascript . ...

How to stop a PHP output buffer from going over the memory limit?

Most of my PHP apps have an ob_start at the beginning, runs through all the code, and then outputs the content, sometimes with some modifications, after everything is done. ob_start() //Business Logic, etc header->output(); echo apply_post_filter(ob_get_clean()); footer->output(); This ensures that PHP errors get displayed within the ...

php access to remote database

Help! I have a PHP (PHP 5.2.5) script on HOST1 trying to connect to an MySql database HOST2. Both hosts are in Shared Host environments controlled through CPanel. HOST2 is set to allow remote database connections from HOST1. The PHP connect I'm using is:- $h2 = IPADDRESS; $dbu = DBUSER; $dbp = DBPASS; $DBlink = mysql_conn...

Creating a file inside a folder that doesn't exist yet in php

I want my php script to create an output file in a folder based on the date. The way I'm doing this is that its supposed to get the foldername/filename from a text file outputted by another program which I am unable to edit. So the file its grabbing the data from looks like this: data/newfolder/10302008/log_for_Today.txt | 24234234...

How do I write unit tests in PHP?

I've read everywhere about how great they are, but for some reason I can't seem to figure out how exactly I'm supposed to test something. Could someone perhaps post a piece of example code and how they would test it? If it's not too much trouble :) ...

PHP __get and Private class variables

Assuming one has an abstract base class "foo" with __get() defined, and a child class "bar" which inherits from foo with a private variable $var, will the parent __get() be called when trying to access the private $var from outside the class? ...

Does Perl have PHP-like dynamic variables?

Hello, In PHP, I can write: $vname = 'phone'; $$vname = '555-1234'; print $phone; ... And the script will output "555-1234". Is there any equivalent in Perl? Edit: Thanks, CMS. Is there any way to constrain $phone to the scope of the local block, as if I'd written "my $phone"? Using "my $$vname" gives me "Can't declare scalar dere...