php5

PHP simplexml_load_string include form field data

Hi All, i have a form on a php5 page. All i trying to do is parse out some xml entered into that form (COMMAND) using simplexml_load_string here is the test code: //BEGIN ' . $Input .XML; $xml = simplexml_load_string($Data); var_dump($xml); } else } echo 'WTF!' } ?> Test ' ...

Problem in fomating date, when using date function with strtotime function ..

Hi, I am using date function along with strtotime function to format the date. Ex: <?php $input_date = '03-JUL-09 14:53'; $formatted_date = date("Y-m-d H:i:s", strtotime($input_date)); echo $formatted_date; ?> Gives me a expected output: 2009-07-03 14:53:00 while if the input is changed to(I am removing the minute part)- <?php...

How to troubleshoot PHP processes

I've built a script in PHP for a small shop that does a few things. Initiate a DB connection, and query the DB a couple times. Read/Write Sessions Make a request to PayPal PDT with fsockopen() parse the results save the order to db After some testing, the server stopped loading. Support let me know that there were 20 PHP processes runn...

How to remove an HTML element using the DOMDocument class

Is there a way off removing an HTML element by using the DOMDocument class? ...

Unload dynamic class in PHP

I implemented dynamic loading of plugins in the following way: function processPlugin( $plgFile, $db ) { require_once( $plgFile ); $plgin = new PlginImpl(); $plgin->setDb($db); $ret = $plgin->process(); return $ret; } Each plugin defines a class named PlginImpl, which works fine. But it should be possible to call further plu...

multiple mysql queries into one php two-dimensional array

I'm refactoring my code and just hit a snag. The first query in the code below gets the tab_id of the latest submitted tabs. The second Query gets the detail of each tab. In my old way of doing it, i embedded php and html and it was truly an utter mess. Right now I'd like to merge the 2 queries into 1 and/or load it into an array. feel...

Strange behavior when using sockets

Hi, I'm getting this strange behavior when fetching a website using socket. The string returned from get_content() function below include some "extra information" that are not present on the original website. function get_content($a, $b, $c = "00") { $request = "arg01=" . $a; $request .= "&arg02=" . $b; $request .= "&arg...

Best Practices for __get() and __set()

Stemming from this question on using __get() and __set() to access private variables, I'd like to get the input on how they are used in general. I am wondering when or where would be the best time to use a overloading function, and where you have used one (if you have). Just to be clear, we are talking about these functions: http://us2....

Is it feasible to develop a chat app using php sockets?

Hi, I'm looking to develop a chat application using php sockets, I'm not looking to include database as a bridge between nodes, reason being the amount of database interaction will ultimately be an overhead..Pls suggest.. ...

PHP 5 Include Class Into Another Class

Hi, I've the following class that I wish to include in all my other classes, but when I use the include or include_once commands my PHP page fail. <?php /** * Configuration class * * @author LennieDG * 25 July 2009 */ class CConfig { public static final $DB_HOST = "..."; public static final $DB_NAME = "..."; public sta...

Alternative to enum types in PHP5?

I have one PHP5 object passing messages to another, and would like to attach a type to each message. For example, MSG_HOT, MSG_WARM, and MSG_COLD. If PHP5 had an enum type, I would probably use that to define the message types, but (unless I'm mistaken) there is no such animal. I've looked at a few options: Strings ('MSG_HOT', 'MSG_WARM...

PHP Image Resize / Relocate - Speeding it up

I've written a little function to take a url, and resize the image and store it on my local, however the script is taking about .85 seconds to run when it needs to create the folder, and .64 seconds on a resize. I currently have JPEG and PNG supported as seen below. I'm wondering if there is a quicker method or something I'm doing that...

How to remove a piece of HTML tags in a HTML page using PHP

I have a situation. I read in a html page using php using this piece of code $body = file_get_contents('index.htm'); Now in the index.htm file is a piece of html code like below that I sometimes need to remove/depends on criteria, so sometimes it needs to be removed and other times not. <td><table><tr><td></td></tr></table></td> How ...

Advanced OOP in PHP5?

I want to know more about OOP in PHP 5.2. Can anybody help me with a link to advanced OOP tutorials in PHP? I know about static, public and private class member attributes, I need more info about basic and advanced OO techniques. I hope somebody can help. :) Thanks a lot to all. ...

Pchart with mouseover

Hello, I have pcharts on my website. I want to add some javascript function for client side facility. If any user mouseover on graph,it shows values on tooltip. Is it possible? Can anybody know how can i do this? Please help me. ...

Wordpress PHP Image change depending on a language

I am trying to write a piece of code that would allow me to change images or a whole block of a div depending on the language <?php if($_SESSION['lang'] == "fr"){ echo "images/header-fr-4.jpg"; }else{ echo "images/header-4-en.jpg"; } ?> Is there any other way of doing this in wordpress? ...

Errors linking libresolv when building PHP 5.2.10 from source on OS X

To begin with, I would normally opt to use a pre-compiled binary of PHP, but am required to build from source for a specific business need. (I'm not the type that compiles open-source apps just for kicks.) I'm building on OS X 10.6 and am running into the following error when I try to make PHP 5.2.10 as an Apache module (--with-apxs2): ...

Working on php switch-case logic

I am working on accessing a db table that will read through a text entry to find a string...then based on that string, create a new variable. Here's the source: <?php $haystack = "Additional Licenses: +2 Licenses /br/ Back-up CD-ROM: No"; $needle = "+0"; switch ($needle) { case '+1': if (strstr($haystack, ...

PHP Syntax ${"{$type}_method"}

I've been reading an PHP5 book, and the author commonly used this syntax ${"{$something}_somethingelse"}; I have no idea what that means. Does it dynamically generate a variable name? Someone help me out? ...

PHP Is there anyway I can simulate an array operator on the return value of a function

In C# and other languages, I can do something like this $value = $obj->getArray()[0]; But not in PHP. Any workarounds or am I doomed to do this all the time? $array = $obj->getArray(); $value = $array[0]; ...