php

How can I add multiple divs or fieldsets to a zend_form using decorators?

I'm trying to generate this html heirarchy in my zend_form display group: <div class="settings"> <div class="dashed-outline"> //want to add this div <fieldset disabledefaultdecorators="1" id="fieldset-settings"> <legend>Cards</legend> </fieldset> </div> </div> This is what I have cur...

Checking if language is set in url with regex

I have am working on a multi language file. My urls look something like this: http://www.mydomain.com/en/about/info http://www.mydomain.com/nl/about/info Now I use a small regex script that redirect the user when they use a link without language. The script looks like this: preg_match('~^/[a-z]{2}/~', $_SERVER['REQUEST_URI'] This f...

How can I see a variable defined in another php-file?

I use the same constant in all my php files. I do not want to assign the value of this variable in all my files. So, I wanted to create one "parameters.php" file and to do the assignment there. Then in all other files I include the "parameters.php" and use variables defined in the "parameters.php". It was the idea but it does not work. ...

Require_once to variable

I want to call require_once("test.php") but not display result and save it into variable like this: $test = require_once('test.php'); //some operations like $test = preg_replace(…); echo $test; Is it possible? ……………………… Thank you guys! :) Solution: test.php <?php $var = '/img/hello.jpg'; $res = <<<test <style type="text/css">...

Imagick PHP Extension -- Montage help?

Hello all, I've been having some trouble generating an image with the Imagick PHP extension. Everything works fine, except my following "montage" has a white background and therefore I cannot overlay it on top of something else. How can I generate a montage with a transparent background? $Montage = $Icons->montageImage(new imagic...

question about soapClent in php

Hi guys! I have a question, I´m developing a web page and I communicate with a server via SOAP. my code is in php. $client = new SoapClient(null, array("location" => "$serverpath", "uri" => "$namespace", "style" => SOAP_RPC, "use...

How to create simpliest PHP Get API with UTF-8 support?

How to create simpliest *(less lines of code, less strange words) PHP Get API *(so any programm made in .Net C# could call url like http://localhost/api.php?astring=your_utf-8_string&amp;bstring=your_utf-8_string ) with UTF-8 support? What I need Is PHP API with one function - concatinate 2 strings so that a simple .net client like thi...

Weird behavior of curl and facebook

Here is the code: $ch = curl_init( 'https://graph.facebook.com/btaylor'); curl_setopt( $ch, CURLOPT_USERAGENT, '' ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER ,true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $data = curl_exec($ch); print_r( $data) ; curl_close($ch); It shows few informations from facebook. It works on my local...

ANY way to consolidate this code?

I am building a PHP registration form which takes the following fields for up to 20 athletes: First Name Middle Initial Last Name Federation Number Address City State Zip DOB SSN Phone Email I am only through 7 of the fields for each fighter and my php file is very large (over 40kb). Is there ANY way to consolidate this code at...

nesting classes in php

here is my sample class to why i want to nest. include("class.db.php"); class Cart { function getProducts() { //this is how i do it now. //enter code here`but i dont want to redeclare for every method in this class. //how can i declare it in one location to be able to use the same variable in every method? $db = new mysqlDB; $que...

RealPath returns an empty string

Hello all, I have the following which just loops through the files in a directory and echo the file names. However, when I use realpath, it returns nothing. What am I doing wrong: if ($handle = opendir($font_path)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != "a.zip") { ...

Send jQuery array to PHP post?

I have a javascript function that gathers two arrays, imagepaths and captions. I want to send with PHP's post to the same page $_SERVER['PHP_SELF'], but I really don't know where to start.. PHP: if (isset($_POST['Submit'])) { $edit_photos->update_xml($edit_photos->album_id, $_POST['src_arr'], $_POST['caption_arr']); // prevent ...

what should i put in this if statment to save the the current array value to a variable

if (preg_match('/^([0-9]( |-)?)?(\(?[0-9]{3}\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4}|[a-zA-Z0-9]{7})$/', $buffer, $matches)); { $variable = ?; } ...

Creating a calendar in PHP

Are there any APIs or libraries that make it easy to generate a calendar for a certain month/year? I need to have some sort of admin interface for a "event planner" part of a CMS for a local youth group and I'm at a loss as to how to generate a decent calendar. Note: I only need something to generate the calendar HTML, not manage events...

Add parameter to PHP

When I sent an image to the code below, uploadImage.php, through a POST method, how do I add a String parameter? <?php $hasError = false; foreach( $_FILES as $i=>$file ) { if ( $file['error'] ) { $hasError = true; } } if ( ! $hasError ) { $myFilePath = '_uploads/'.'_'.$file["name"]; $dta = file_get_contents($...

Is it best practice to try - catch my entire PHP code, or be as specific as possible?

I do not have many kinds of Exceptions in my project. Right now,(we use MVC) I have the try catch encompassing my entire code: try{ fronController::dispatch($somthing...); }catch(Exception $E){ //handle errors } I wonder if there is a good reason to use the try-catch block in as specific as possible way as I can or just keep it g...

Wordpress' post_time won't work with Custom PHP time difference calculator.

Hey guys, i'm using this script (http://snipplr.com/view/4912/relative-time/) to create relative times using PHP and timestamps stored in my database. I'm using the standard format for storing datetime (eg 2010-05-07 20:26:17) and it works fine with any timestamps i create. But for some reason when i try to use a timestamp stored in wor...

phpUnit - mock php extended exception object

I'm testing some legacy code that extends the default php exception object. This code prints out a custom HTML error message. I would like to mock this exception object in such a way that when the tested code generates an exception it will just echo the basic message instead of giving me the whole HTML message. I cannot figure out a w...

How to extract block of XML from a log file on Linux

I have a log file that looks like the following: 2010-05-12 12:23:45 Some sort of log entry 2010-05-12 01:45:12 Request XML: <RootTag> <Element>Value</Element> <Element>Another Value</Element> </RootTag> 2010-05-12 01:45:32 Response XML: <ResponseRoot> <Element>Value</Element> </ResponseRoot> 2010-05-12 01:45:49 Another log entry What...

Retrieving multiple rows from a loop-created form... Stuck.

Let me start by saying that I'm new to PHP, but I'm here to learn and would really appreciate your help. I use the following code to pull in data and create a form. This creates up to 40 lines for a user to fill out. Each line consists of the same information: Description, Amount, and Frequency. The remainder of the information needed ...