php5

Find multiple string positions in PHP

I`m writing a PHP page that parses given URL. What I can do is find the first occurrence only, yet when I echo it, I get another value rather than the given. this is what I did till now. <?php $URL = @"my URL goes here";//get from database $str = file_get_contents($URL); $toFind = "string to find"; $pos = strpos(htmlspecialchars($str),...

How can I make use of PHP data cache in export to csv or txt

What is the advantage of PHP data cache ? Where i can use that , is it good only for browser search or it is good for data export to csv or text also . How can i achieve data cache using PHP? ...

Where can I find PHPUnit_Extensions_SeleniumTestCase?

I have Selenium IDE/RC, and PHPUnit 3.5 (PEAR) installed, but I can't seem to find PHPUnit_Extensions_SeleniumTestCase. When I type pear install phpunit/PHPUnit_Selenium, I get the following error: phpunit/PHPUnit_Selenium is already installed and is the same as the released version 1.0.0 install failed It appears that PHPUn...

how to do this in regex?

I'm building an app with several languages. test.com/ -english index test.com/ca - canadian english index test.com/canada-promo - english version of canada promo page test.com/ca/canada-promo - canadian english version of promo page how would I filter this? sorry about that. there are actually 4 languages (/fr/ and /es/). I want to b...

PHP 5.3: mysqli_multi_query and "commands out of sync" errors

When I use mysqli_multi_query() with a mass INSERT query, then after the query has run do another query using mysqli_query('SELECT...'), I get "commands out of sync" errors. Does anyone know why this happens? ...

Social-networks sharing links in RSS

Does anyone know how to add social-networks sharing links to an RSS feed, similar to how CNN does here? BTW I work with PHP code. link text ...

Track Email actions back to PHP controllers - How To?

Hi! Sometimes on Facebook or from other websites I get emails with URL links that are encoded with specific actions the server is meant to interpret when it receives a call to that link - here's a semi-made-up example: http://apps.facebook.com/yourApp/tracks.php?sendkey=11bc3efa06&amp;next=reward_link.php%3Fp%255BlahBlahBlah (NOT A REAL...

Multiple discrimination levels while using Doctrine2

I'm using Doctrine2 to manage my model below: There's an abstract concept Content with a Composite pattern in Gallery, also an abstract concept Media from which Video and Image inherits. My choice was to add discriminators to Content and Media tables in order to differentiate between Gallery, Video and Image. Content uses JOIN inherit...

php find characters in url

I want to use php to search the current url for com_agora and if it finds it to display something and if it doesn't to display something else the problem is there can be lots of characters after com_agora in the url an example would be this com_agora&task=cat_view&gid=41&Itemid= so how would I tell it find it while not caring what ch...

PDFlib give pdf_fit_textline a border

I'm generating PDFs dynamically using PHP and PDFlib and some of the fields require text being centered on blank fields lines (like you would see on a paper form). To make sure I have the text field using the maximum width available to me as well as positioned properly I would like to place a temporary border around it so I can see where...

LDAP validation using email address?

I am using LDAP validation , now LDAP id am using and its working fine. I want to use email instead of ldap id. How can i add that. What will be LDAP config for this ? now this is working $username='ou=users,o=example.com'; this is not working $username='mail='.$user.',ou=users,o=example.com'; how to use email for ldap validation ...

How to know if a user has a facebook account ?

I need to know if the users of my website has logged to facebook in the past 30 days. Can I know this through facebook cookies or in another way ? ...

in php, a function's arguments can be a word without quotes or $

I always thought that the arguments of a function in PHP should be either a string enclosed by '', or a number, or a variable. However, looking at this in php.net's manual I see: public function baz(Test $other) What does the word Test here refer to? How is this possible? ...

Zend Imap Connection timeout

I'm using Zend framework provided IMAP classes to access gmail messages over imap. I access the message headers of all the messages in the inbox one by one and index them locally. The script works fine for inboxes with messages less than 10000. For larger inboxes the script looses the connection, probably a timeout. Here is the stack tr...

Is it bad to use Reflection in production code?

I've got a Validator class which creates an instance of a Validations class, which contains all the validation methods. When a validation is performed, __call in Validator is used to dispatch a call Validator->validate_method to Validations->method. So for instance, there is a method in Validations called length_of. When the following c...

Zend PDF image bad quality

Hi ! I've tried Zend PDF and it works pretty well but I have a troublesome problem : when I add an image to a page with drawImage() it always appears pixilated regardless position and dimensions. There's many lines I don't understand in the Zend images classes, has someone already encountered this problem? How can I fix this ? (I canno...

How can I parse this HTML with a regular expression in PHP?

Hi, I'm working on regular expression to find a whole heap of text that sits inside <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; and a tag that says end of menu... which looks like this: <!--END MENU--> This is the code i wrote but it's not spitting o...

Developing an API layer. Need some advice and feedback about usage of Decorator pattern.

Hi, I am developing an api layer for my application. I have designed a structure and need some advice/feedback for it. You can find the basic implementation of the structure at the bottom. Here are my requirements for the structure: Response from API commands may need to be formatted in different formats (JSON,XML,etc.) Some API com...

PHP Curl sending an empty array

Ok, I've checked the other questions similar to this one, and none seem to point out to a solution to my problem. I have the following code: <?PHP $tamanho = $_REQUEST['tamanho']; $post_data['item_quant'] = $_REQUEST['item_quant']; $post_data['email_cobranca'] = $_REQUEST['email_cobranca']; $post_data['tipo'] = $_REQUEST['tipo']; $post...

Calling action helper from action helper problem - undefined view variable

So I have an action helper (from which I call a second action helper): <?php class My_Controller_Action_Helper_Helper1 extends Zend_Controller_Action_Helper_Abstract { public function direct() { $theActionController = $this->getActionController(); $helper = Zend_Controller_Action_HelperBroker::getStaticHelper...