I have taken a liking to jQuery/Javascript's way of extending functionality via closures. Is it possible to do something similar in PHP 5.3?
class Foo
{
public $bar;
}
$foo = new Foo;
$foo->bar = function($baz) { echo strtoupper($baz); };
$foo->bar('lorem ipsum dolor sit amet');
// LOREM IPSUM DOLOR SIT AMET
[edit] mixed up 'it' ...
In a lot of my PHP projects, I end up with classes that have non-public functions that I don't intend to extend.
Is it best to declare these as protected, or private?
I can see arguments both ways - making them private is a far more conservative approach, but it can be argued that they could be made protected later if I want the method...
Does anyone know how to maintain text formatting when using XPath to extract data?
I am currently extracting all blocks
<div class="info">
<h5>title</h5>
text <a href="somelink">anchor</a>
</div>
from a page. The problem is when I access the nodeValue, I can only get plain text. How can I capture the contents including formatting, i...
We are migrating to a new server running Windows 2003 and IIS 6. When my PHP code runs, it has a warning on a particular line (which I'm expecting at the moment but will fix shortly). However, when it hits the warning, it immediately halts processing and returns a 500 error in the HTTP header. Normally, I would expect PHP to output the w...
What is best practice to create dynamic sidebar or other non content layout places with zend framework. At this moment I created controller witch i called WidgetsController. In this controller i defined some actions with 'sidebar' response segment for my sidebar and in IndexController i call them with $this->view->action(); function but ...
Hi This is either a very specific or very generic quetion - I'm not sure, and I'm new to the Zend framework / oo generally. Please be patient if this is a stupid Q...
Anyway, I want to create a model which does something like:
Read all the itmes from a table 'gifts' into a row set
for each row in the table, read from a second table w...
I'm working on improving one of my client's websites by converting their "FAQ" section to a full blown KB article system with (preferably) nifty AJAX search mechanism. I've done some searching and found a few commercial products but would prefer something open source and wanted some recommendations before I jump blindly in to anything.
...
Let's say I have a page called display.php and the user is viewing display.php?page=3. I want to allow the user to do an action like voting via a POST request and then bring them back to the page they were on. So, If I do a POST request to display.php?page=3 would the page information also be available to the script?
...
Currently I have a bookmarked list of websites that I look for content on, and open them in a new window, in tabs, and search for the string that I want to find.
Is there any way to do this programatically, ending up with a browser window containing the results pages of the sites? There's around 20 of them.
I'm running Safari 3 on Mac ...
I have a relatively simple application up and working with some basic functionality which i have built as a bit of a project. I would like to now build on that, and add some more complex features, including login.
The code has got quite complex, and it's written in plain php, so all the presentation code is mixed in with the logic. I h...
What is the best way to test the speed of a LAMP based site, without factoring in the user's connection?
In other words, I have a CMS and I want to see how long it takes for PHP and MySQL to do all their work.
Additionally I do not have shell access to the server, it is in a shared hosting environment.
...
I'm working on a script that sadly I inherited - with no commenting or anything. Argh!
For testing purposes I duplicated one of the tables in the database which had an auto-incrementing ID. When the data is saved to the database, though, the ID number just reads "0" -- which is the default for that column. I'm not sure why it's not auto...
My table has data like so
products_parent_id | products_quantity
2 5
2 7
2 9
2 4
My SQL statement looks like so (so far):
UPDATE ' . TABLE_PRODUCTS . ' SET products_quantity = products_quantity +' . $order['products_quantity'] . ', products_orde...
Can anyone suggest which of the following Twitter PHP libraries is the best?
My Twitter by Andres Scheffer.
Twitter by Felix Oghina.
TwitterLibPHP by Justin Poliey.
Arc90_Service_Twitter by Matt Williams.
PHP Twitter by Aaron Brazell, original code from David Billingham.
PEAR Services_Twitter by Joe Stump and David Jean Louis.
P...
I am building stats for my users and dont wish the visits from bots to be counted.
Now I have a basic php with mysql increasing 1 each time the page is called.
But bots are also added to the count.
Does anyone can think of a way?
Mainly is just the major ones that mess things up. Google, Yahoo, Msn, etc.
...
I am using Kohana and just found this piece of code in their autoloading method
// Class extension to be evaluated
$extension = 'class '.$class.' extends '.$class.'_Core { }';
// Start class analysis
$core = new ReflectionClass($class.'_Core');
if ($core->isAbstract())
{
// Make the extension abstract
$extension = 'a...
include('header.php');
$name = $_POST['name'];
$score = $_POST['score'];
$dept = $_POST['dept'];
$MyDB->prep("INSERT INTO demo (`id`,`name`,`score`,`dept`, `date`) VALUES ('','$name','$score','$dept','$date')");
// Bind a value to our :id hook
// Produces: SELECT * FROM demo_table WHERE id = '23'
$MyDB->bind(':date', $date);
// Run the...
Hi there,
I've got some trouble with displaying pdfs in IE7 (which were generated by R&OS' ezpdf).
IE7 with Acrobat Reader 8.1.2. says "The page cannot be displayed"
Other Browsers (like FF3/Acrobat 8.1.2. or IE6/Acrobat 7) have no problem with the file.
The following headers are returned by the server:
Date: Thu, 08 Jan 2009 10:...
If I am to follow What should a developer know before building a public web site? on authentication, then what options do I have ?
I have never used PEAR, and I'm not about to start. I have read about phpGALC but have yet to try it.
After the authentication do rights/access level kick in. I'm not a big fan of using a single tinyint val...
I need to check a string to see if any word in it has multiple occurences. So basically I will accept:
"google makes love"
but I don't accept:
"google makes google love" or "google makes love love google" etc.
Any ideas? Really don't know any way to approach this, any help would be greatly appreciated.
...