php5

How to make mail() work on Ubuntu?

I have a new install of Ubuntu and trying to use the php's mail() function. The function fails, I guess I am missing a package or two in my installation. ...

How to extract the full url (subdomain,domain and directories) with ZF?

Is there a way, using the functionality in ZF, to get the full url (http[s]::/xxx.yyyy.ddd/ggg/hhh) I am currently in? baseUrl() will only give me the path, not the domain and sub domain. I know how to extract it from the $_SERVER, trying to avoid that. ...

Best way to get post info into variables without displaying them in Wordpress

I am writing a Wordpress plugin and need to go through a number of posts, grab the data from them (for the most part title, permalink, and content), and apply processing to them without displaying them on the page. What I've looked at: I've looked at get_posts() for getting the posts, and then getting title via the_title(), content v...

Extract data from PHP Object

I'm using the Facebook API and the class produces this object. object(User)#4 (5) { ["fbc_uid"]=> string(9) "324234324" ["fbc_first_name"]=> string(5) "James" ["fbc_last_name"]=> string(5) "Proud" ["fbc_name"]=> string(11) "James Proud" ["fbc_email"]=> NULL } How do I ...

PHP include_once: handling of imports i.e. for configuration files

Let's assume we have the following structure: index.php config.inc.php \ lib \ lib \ common.php Several parameters like database name, user & co are configured in config.inc.php. What is the proper way to access them i.e. from a function located in \lib\common.php. Do I really have to do an include_once("config.inc.php") within each f...

How do I use PHP CLI to automate FTP when I don't have access to PHP's native FTP handle?

I'm writing an automation script on a production server that, among other things, needs to grab a list of remote files via FTP (FTP is the only option for interacting with the remote filesystem) and selectively download them. Why I can't use PHP's native FTP wrappers This is a production server in a very brittle environment. I'm writi...

PHP key value pairs vs. arrays

I'm trying to pass key values pairs within PHP: // "initialize" private $variables; // append $this->variables[] = array ( $key = $value) // parse foreach ( $variables as $key => $value ) { //.. } But it seems that new arrays are added instead of appending the key/value, nor does the iteration work as expect. Please let me know wha...

Is there a need to pass variable by reference in php5?

With PHP5 using "copy on write" and passing by reference causing more of a performance penalty than a gain, why should I use pass-by-reference? Other than call-back functions that would return more than one value or classes who's attributes you want to be alterable without calling a set function later(bad practice, I know), is there a u...

Faking Late Static Binding before php 5.3

I need an inherited static function "call" to call another static function "inner" that has been overridden. I could do this with late static binding, but my host does not have php5.3 yet and so I need to work around it. class ClassA{ static function call() { return self::inner(); } static function inner(){ r...

Prevent Users from submitting form by hitting enter

Well I have a survey on a website, and there seems to be some issues with the users hitting enter (i don't know why) and accidentally submitting the survey (form) without clicking the submit button. Is there a way to prevent this? I'm using html, php 5.2.9, and jquery, on the survey. ...

Where can I find large php5 best practises project?

I'm trying to find a project that incorporates the "best practices" that are discussed and debated on a daily basis for almost all languages but I'm trying to focus on php5. Is there a php5 open source project that I can comb through to see working examples of project that exemplifies Units Tests, Dependency Injection and other best pra...

Upload text as file with POST (multipart/form-data) using php and curl

The API, I'm trying to implement requires the upload of XML file, containing the commands. The straightforward way to do this is to generate the content of the file, write it on the file system and upload it with curl to the web server. What I'm trying to accomplish is to skip the writing part by using php's temp protocol handler. The ...

Are there any reference PHP Applications with good object orientated practices and design patterns?

I want to find out from community if there are any good applications out there that can be used as a model or reference application for implementing OOP and Design Patterns like MVC? Edit: I am mainly looking for reference applications like magento and not frameworks like Zend Framework. ...

PHP Configuration file won’t load IIS7 x64

using Fast CGI I can't get it to read the php.ini file. See my phpinfo below. System Windows NT WIN-PAFTBLXQWYW 6.0 build 6001 Build Date Mar 5 2009 19:43:24 Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--with-snapshot-template=d:\php-sdk\snap_5_2\vc6\x86\template" "--with-php-build=d:\...

How to solve the case when users surf to index.php

In Zend framework, using the MVC, if A user surf explicitly to http://base/url/index.php instead of just http://base/url, The system thinks the real base url is http://base/url/index.php/ and according to that calculates all the URLs in the system. So, if I have a controller XXX and action YYY The link will be http://base/url/index.php/...

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? ...

Dynamic content with PHP & Smarty

I'm using Smarty and utilizing the config_load respective {#VAR#} variables to implement localization. This is working perfectly fine as long as the content is within the templates, but fails as soon as I have to add dynamic content within the TPL file, i.e. with: {if isset($var) } {foreach from=$var item=line} {$line}<br> ...

Is there any way to put zip file in PHP's include_path?

Copying Zenf Framework everywhere is a nightmare, so I had an idea, thas deployment would be faster if whole framework would ba just a zip file. Is there a way to do that? Would it be very inefficient? ...

adding a Route to the a Router in Zend Framework

I am using the mod-rewrite router. I am trying to add a Route to the router that will convert the following url: baseurl/category/aaa/mycontroller/myaction/param/value to be: Controller=mycontroller action=myaction --parameters-- category=aaa param=value I am using the following (not working) in my bootstrap, _front is the ...

How to specify a dynamic default for a key in a router, Zend Framework

This question is linked to this one How can I set the default of the category part to be the category value in the request url? $Router=$this->_front->getRouter(); $CategoryRoute = new Zend_Controller_Router_Route('category/:category/:controller/:action/*', array( 'controller' => 'index', ...