Skip to content
Advertisement

Category: Questions

Does PHP class property scope overridden by passing as reference?

In PHP, if you return a reference to a protected/private property to a class outside the scope of the property does the reference override the scope? e.g. Is this correct and is the array bar being passed by reference? Answer Well, your sample code is not PHP, but yes, if you return a reference to a protected variable, you can

How do I use PHP to get the current year?

I want to put a copyright notice in the footer of a web site, but I think it’s incredibly tacky for the year to be outdated. How would I make the year update automatically with PHP 4 or PHP 5? Answer You can use either date or strftime. In this case I’d say it doesn’t matter as a year is a year,

Compile a PHP script in Linux

I know PHP scripts don’t actually compile until they are run. However, say I want to create a small simple program and compile it to a binary without requiring the PHP binary. How could I do this? I’ve seen a few IDE’s out there that would do this, but either they are all for windows or the Linux versions don’t

PHP equivalent of .NET/Java’s toString()

How do I convert the value of a PHP variable to string? I was looking for something better than concatenating with an empty string: Like the ToString() method in Java or .NET. Answer You can use the casting operators: There are more details for string casting and conversion in the Strings section of the PHP manual, including special handling for

How do I install the php_gd2 extension in MAMP on a Mac?

I’m running MAMP 1.7.2 on a Mac and I’d like to install the extension php_gd2. How do I do this? I know that on Windows using WAMP I’d simply select the php_gd2 entry in the extensions menu to activate it. How is it done when using MAMP? I know that I can do it using MacPorts but I’d prefer not

php Zend / MVC without mod_rewrite

I’ve seen it mentioned in many blogs around the net, but I believe it shoud be discussed here. What can we do when we have an MVC framework (I am interested in ZEND) in PHP but our host does not provide mod_rewrite? Are there any “short-cuts”? Can we transfer control in any way (so that a mapping may occur between

Variable parameter/result binding with prepared statements

In a project that I’m about to wrap up, I’ve written and implemented an object-relational mapping solution for PHP. Before the doubters and dreamers cry out “how on earth?”, relax — I haven’t found a way to make late static binding work — I’m just working around it in the best way that I possibly can. Anyway, I’m not currently

Advertisement