php

how to make variables in pre_controller hooks global to all controllers?

in my pre_controller hook i have this code for doctrine: $manager = Doctrine_Manager::getInstance(); $conn = Doctrine_Manager::connection($db[$active_group][‘dsn’]); then in my controller i have this code to use doctrine connection i’ve created: $conn->export->createTable(‘test’, array(‘name’ => array(‘type’ => ‘string’))); $conn-...

is there an abstraction layer for XML?

i wonder if there is a good abstraction layer for XLM like ORM for databases? is it a good solution or is it better to use simple_xml for xml CRUD? ...

Is there any way to redeclare a class safely in PHP?

We all know the infamous "cannot redeclare class" error. Is there any method to overcome this and actually declare a new class with the same name, or is this impossible in PHP 5? ...

Differences between Zend Framework 1.8 and 1.10

I want to start learning Zend Framework. My only concern is that the most recent ZF book on Amazon with good reviews teaches version 1.8 of the framework, which is now about a year old. Do you think it would be a good idea to still pick up that book or is it too old now? ...

Help with OpenSSL request using Python

Hi i'm creating a program that has to make a request and then obtain some info. For doing that the website had done some API that i will use. There is an how-to about these API but every example is made using PHP. But my app is done using Python so i need to convert the code. here is the how-to: The request string is sealed with Ope...

PHP: question about passing parameters in URL's

Hi, i have this two lines: var_dump($parametros_post_signin); $this->redirect('prueba/aux?email='.$parametros_post_signin['signin']); the first one prints this: array 'signin' => array 'email_address' => string '' (length=0) 'password' => string '' (length=0) the second one takes to another action where i h...

Can PHP Includes be used to onClick load one page inside another.

Need to load the content of one page inside another to simulate tabbed panels. The current methods I have tried do not work. Iframe does not readjust size to conform with the collapsible panels and with ajax the collapsible panels and calculating scripts do not work at all. Testing area is located here http://www.divethegap.com/scuba-d...

How to Limit Text Characters in PHP?

I was wondering how can I limit a users input like HTML maxlength attribute but with PHP, example would be nice? Is MySQL varchar(255) one way to limit a users character input? What are the cons of just counting on MySQL to do this? ...

PHP memcached Fatal error: Class 'Memcache' not found

I've pasted the example from php.net for using memcached in php and I'm getting: Fatal error: Class 'Memcache' not found I have this in my php.ini: [memcache] memcache.hash_strategy = "consistent" memcache.max_failover_attemps = 100 memcache.allow_failover = 1 Here's info from php -i and php -m respectively: php -i |...

Remove excess empty directories in uploaded zip file.

Hello, I am trying to remove excess directories from an uploaded zip file. For example I would like to transform : /folder1/folder2/folder3/ [Files are in this folder] to /folder1/[files are in this folder] Any help would be appreciated, Thanks. Hello, I am trying to remove excess directories from an uploaded zip file. For ex...

problem when migrating from development into live server

I'm facing problem when migrate my web app project from development server to live server. the reason is because i just realize that the live server has different PHP version and available memory lower then mine. i found this after client give me their ftp and cpanel access of their server, which is a shared host. so, how do we han...

Filter Facebook Stream by Post privacy?

Hi there, i query some wall data within my facebook tab. I was wondering how to filter the data (query) to show only post which are visible to a certain country. $query = " SELECT post_id, created_time, attachment,action_links, privacy FROM stream WHERE source_id = ".$page_id." ...

Making Vim auto-indent PHP/HTML using alternative syntax

I edit PHP in Vim and have enjoyed the auto-indenting, but PHP's alternative syntax doesn't auto-indent how I would like. For instance, in an HTML template, Vim doesn't recognize the open control structure in the same way it does when using braces. Example: <html> <body> <p> <?php if (1==1): ?> This line should be inde...

Is PHP's json_encode guaranteed to produce ASCII string?

Well, the subject says everything. I'm using json_encode to convert some UTF8 data to JSON and I need to transfer it to some layer that is currently ASCII-only. So I wonder whether I need to make it UTF-8 aware, or can I leave it as it is. Looking at JSON rfc, UTF8 is also valid charset in JSON output, although not recommended, i.e. som...

PHPDoc Function Changelog (@change?)

What is the best way to document changes in a function with PHPDoc? Something like @change 2010.20.16 user added feature x @change 2010.20.26 user added feature y would be great. But assume there's no @change option... If i add it anyways, what will PHPDoc do with it? Or is there a better / more correct way to document function ch...

Best way to password protect a folder?

I am trying to create a similar way to Cpanel password protect directory, where a pop up comes out asking the user for a username and a password, but Cpanel way is amazing but my client doesn't know anything on how to do that, so i wanted to create a pop up msgbox informing the visitor to enter a user name and a password, and i totaly co...

PHP constants declaration based on condition

I am using one separate file for all constants of my PHP application. class constants { const USERNAME = 'abc'; /* ⋮ */ } For lets say USERNAME constant, value can be either xyz or abc based on file exists check. If xyz file exists USERNAME value would be xyz. How can I do this check in my constants class? Thanks in ...

How a database is loaded into an application?

Hi All i need is a simple explanation on how does this function work I also attached a piece of php which I think is the one that retrieves the data from the database. Please correct me if I'm wrong Cheers. function loadDatabaseRecords () { // Mozilla/Safari if (window.XMLHttpRequest) { xmlHttpReq = new XMLHttpRequest(); } // ...

Set php file permissions so only my server's curl can run

I have a PHP script that I don't want anyone to be able to run through their browser. It sends emails and is called via curl by my server's cron, yet needs to be in the public www directory. What permissions or owner do I need to set the file to to allow only my server's curl to execute (or do I mean read) the file? I'm on centos. ...

Resizing iframe height using javascript issue

I have an iframe which content is a php-file, and that php-file displays some mysql records. The more records, the larger the iframe height should get, otherwise it wont show all of the information in the iframe. Here is a code I have for dynamically setting the iframe height, from the iframes content (the php file): var x = document....