php

Any good documentation/tutorials for PHP's Mailparse pecl extension

I'm looking for guidance on how to use PHP's Mailparse pecl extension. The documentation on the PHP website isn't very helpful. Does anyone have experience with this and care to share a few pointers? ...

How do I get a PHP script to send and receive data from an already running process?

I'm trying to create a simple AJAX to Telnet client for the web. I may be re-inventing the wheel by doing this, but it is a learning project for myself. At the moment I haven't written anything, I'm just trying to get the idea wrapped around my brain. It doesn't necessarily have to be PHP. If I have a telnet client that supports multipl...

Zend_Paginator blurring MVC lines

I'm working on a Zend Framework (1.7) project with a structure loosely based on the structure of the quickstart application - front controller, action controllers, views & models that use Zend_Db_Table to get to the database. One of my main models relies on some expensive joins to pull up its primary listing, so I'm looking into using Z...

Refactoring a massive function into many files.

I've been trying to refactor a "bit" of code that I'd previously developed. Basically, the project was my response to not knowing how to use XSLT effectively, so I developed an XML transformation system in PHP. The program reads through the tags of an XML file and does something along these lines to convert it to HTML: private function ...

Retrive browser and OS in PHP

Hi friends, I need to retrive the browser and OS through php coding. I had used $_SERVER['HTTP_USER_AGENT'], but its shows the following Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; IEMB3) How can i separate the browser and Os from the above received value.. Please guide me.. Thanks in...

regexp for finding everything between <a> and </a> tags

Hi, I'm trying to find a way to make a list of everything between <a> and </a> tags. So I have a list of links and I want to get the names of the links (not where the links go, but what they're called on the page). Would be really helpful to me. Currently I have this: $lines = preg_split("/\r?\n|\r/", $content); // content is the giv...

PHP - how to distinguish command-line and web-server invocation?

Is there a way to distinguish if a script was invoked from the command line or by the web server? (See http://stackoverflow.com/questions/173851/what-is-the-canonical-way-to-determine-commandline-vs-http-execution-of-a-php-s for best answer and more detailed discussion - didn't find that one before posting) I have a (non-production)...

html getting garbled from php

Hello, I have a mysql database which as one of the fields contains a html description. This description is not in my control, and is obtained and inserted automatically. An example of one of these descriptions is here: http://www.nomorepasting.com/getpaste.php?pasteid=22492 The data is originally exported from an access database, and ...

PHP debugging - where to set the breakpoints? how to authenticate?

So I've just recently made the step from ad hoc debugging with dump, print_r and echo to some more sophisticated methods and I'm having a struggle. I work with Zend Framework, Aptana and Zend Debugger. At this moment I'm trying to debug a custom controller and whatever I try I don't get to my breakpoint which I understand since there ...

PHP: What has changed since 2004?

I started using PHP for creating online database driven applications in 1998. Back then, PHP 3 was the state of the art for web development. In the following years I've written a whole bunch of applications and a self-tailored framework for content management and document archiving (which I'm sure is ridiculous compared to solutions that...

PHP crypt() function in .Net?

I'm rewriting a PHP web site in ASP.NET MVC. I'd like to maintain the same user base but the passwords are hashed using the PHP crypt() function. I need the same function in .Net so that I can hash a password on login and check it against the hashed password in the user database. crypt in this case is using the CRYPT_MD5 implementation ...

Handle requests to several classes within the same PHP SOAP server

Hi, Is that possible to have a single PHP SOAP server which will handle requests to several classes (services)? If yes, could you please show an example implementation? If not, could you please describe why? Thanks in advance, Artem. ...

What's quicker, an array lookup (including array build) or an IF stack?

I was wondering which was better: $lookup = array( "a" => 1, "b" => 2, "c" => 3 ); return $lookup[$key]; or if ( $key == "a" ) return 1 else if ( $key == "b" ) return 2 else if ( $key == "c" ) return 3 or maybe just a nice switch... switch($key){ case "a": return 1; case "b": return 2; case "c": return 3; } I always prefer the f...

PHP MySQL Search And Order By Relevancy

I know how to do a regular php mysql search and display the results. However, because of the nature of what I'm trying to accomplish I need to be able to sort by relevancy. Let me explain this better: Normal Query "apple iphone applications" will search the database using %apple iphone application%, but if there aren't records which dis...

Set cookies in a php cgi enviroment without using php api

How can I use cookies in a php CGI Enviroment without using any api functions from PHP? ...

Mock Objects in PHPUnit to emulate Static Method Calls?

I am trying to test a class that manages data access in the database (you know, CRUD, essentially). The DB library we're using happens to have an API wherein you first get the table object by a static call: function getFoo($id) { $MyTableRepresentation = DB_DataObject::factory("mytable"); $MyTableRepresentation->get($id); ... do s...

How do I set an absolute include path in PHP?

In HTML, I can find a file starting from the web server's root folder by beginning the filepath with "/". Like: /images/some_image.jpg I can put that path in any file in any subdirectory, and it will point to the right image. With PHP, I tried something similar: include("/includes/header.php"); ...but that doesn't work. I think t...

PHP and PEAR

Hi All, PHP 5 and I want to install PEAR so I can use Spreadsheet_Excel_Writer I dont see how to install it on my ISP nor my personal Macbook. Thoughts for both? Thanks! ...

How do I format a PHP include() absolute (rather than relative) path?

On various pages throughout my PHP web site and in various nested directories I want to include a specific file at a path relative to the root. What single command can I put on both of these pages... http://www.example.com/pageone.php http://www.example.com/somedirectory/pagetwo.php ...to include this page: http://www.example.com/in...

PHP and SQL Server debugging

I'm working on a script in PHP that needs to get some info from a SQL Server database. However, I am having trouble connecting to the database. When i use the mssql_connect() function, it gives me an error and says it cannot connect to the database. However, it gives no reason why. Is there any way to find out why it won't connect? There...