php5

Get all constants from class

Is it possible to fetch all defined constants from class ? I.e. I have following class: class Cl { const AAA = 1; const BBB = 2; } and I would like to get an array: array ( 'AAA' => 1, 'BBB' => 2, ) ...

PHP: Can We Replace PHP Language Construct With Our Own?

Hello All, PHP allows you to replace or even re-name PHP's built-in functions using functions such as override_function and rename_function. Can we override the PHP's language constructs like the ones below? echo eval ...etc ...

Unable to upload file to ftp server using php

I am trying to upload file to FTP server using php but it is not getting uploaded. Code: $response =<<<RESPONSE <cdm:Response> <cdm:header exportTime="{$export_time}" baseVersion="{$baseline_snapshot_id}" version="{$this->snapshot_id}"> <cdm:countryCode>{$this->domain}</cdm:countryCode> <cdm:descript...

PHP SimpleXML Error Message

Warning: main() [function.main]: Node no longer exists I am loading a ml file via simplexml_load_file, it sometimes has values for an attribute and sometimes does not. Usage: $value = $xml->Name->arttributes(); Echo $value; how do I error check to see if there is a value without getting a warning. Thanks ...

How to load dynamic image w/php gd library, w/o saving it on server or having src="script.php" ??

I would like to generate a dynamic image from a script, and then have it load to the browser without being persistent on the server. However, I cannot call this by setting the image's src="script.php", since that would require running the script that just generated the page and its data all over again, just to get the final data that ...

Object Design Question User and Access Role in PHP with SQL

Hi, how do you design your objects lets say you have an object user and an object access_role. The user is stored in users table in an sql database, the access_role knows the user_id and is stored in an sql database. class user() { protected $_name; protected $_id; protected $_age; protected $_password; public...

Comparing and highlighting phrases in text with php

I have an array of words $duplicate_words and a string $contents. I want to search for the words in the string and highlight them when there is a match. I can highlight single duplicate words, but I don't want to highlight single words - I want to highlight only when two or more words match there. I've been trying to find a solution fo...

error in media wiki php code

$wgAuth = new HttpAuthPlugin(); - After this line, control is not reachin the next line, not printin the next log. error_log("JITEN TEST :WGAUTH object created, Value of wgAuth is :" . $wgAuth . "\n", 3, $logfile); $wgHooks['UserLoadFromSession'][] = array($wgAuth,'autoAuthenticate'); error_log("JITEN TEST :Value of wgAuth is :" . $w...

How do I access programmatically the url where my index is located in CakePHP?

Ex: echo getMyUrl(); should echo: http://localhost/myapplication ...

How to record the name of the file/line that called the current function in PHP?

I am writing a lightweight logging class in php. How do I automatically record the filename/function/line number where the function in the Log class is being called from and save the line number and time and stuff without making my users bother with entering $__LINE__ and $__FILE__ every time they call the function. Is there something ...

How can I improve my PHP code to make it more efficient?

I've written a simple PHP script which checks if a random value is a valid Rugby Union score. It works quite nicely but isn't particularly efficient, any advice on improving it would be most welcome. $score = rand(0, 60); /* Rugby Union * * Try = 5 points * Conversion = 2 points * Penalty = 3 points * Drop goal = 3 points * */...

PHP4 constructor naming convention in PHP5

Aside from the "you won't have to change the name", is there any real problems with retaining the PHP4 style constructor names: ClassName($args) in PHP5? ...

How to get compatible with php4 in a framework developed with php5

Hello There, How to get compatible with php4 in a framework developed with php5? Thanks ...

Wordpress Undefined property: stdClass::$post_type

I'm getting this error on my blog did some one had the same error? how can i fix the error? I didnt edited any File. Notice: Undefined property: stdClass::$post_type in /home/a4673438/public_html/wp-includes/link-template.php on line 105 Notice: Undefined property: stdClass::$post_status in /home/a4673438/public_html/wp-includes/li...

IE giving error on XML code embeded with PHP.

This code works fine on browsers other than IE. echo " <item> <link>http://www.example.com/showrssdetails.php?id=".$row[recordid]."&lt;/link&gt; <guid isPermaLink=\"true\">http://www.example.com/showrssdetails.php.php?id=".$row[recordid]."&lt;/guid&gt; <title>".$row[company]."</title> <description><! [CDATA[".$row[desiredcandidate]."]]>...

Choosing the right PHP framework

Could someone possibly help me choosing a PHP MVC framework? My requirements are: SIMPLE authentication system (no need for ACL, just isAuthenticated(), isInRole() Resources and RESTful approach Helpers (Html, Ajax and such stuff) It would be nice if it was PHP 5 only I've tested some frameworks. CakePHP seemed good to me, but it has...

Zend Framework And XML/XSLT Integration

Hello, I'm trying to use XML files and XSL stylesheets instead of ordinary phtml templates in Zend Framework. I'm not sure how to implement it, though. What I've tried to do so far: instead of .phtml views I use .xsl stylesheets I use .xml layouts Here is what I do in the init() method of each controller: $this->view->xmlStyleshee...

how to do only selected folders with a PHP 5 iterator?

I am trying to use the PHP recursive directory iterator to find php and html files in order to list those by date. The code used is as follows: $filelist = array(); $iterator = new RecursiveDirectoryIterator( $this->_jrootpath ); foreach(new RecursiveIteratorIterator($iterator) as $file) { if ( !$file->isDir() ) { if ( preg_...

Setting include_path in a shared php.ini file

I have 2 Macs whose general configuration I want to keep sync'd. For Apache and PHP, I store the conf files (httpd.conf and php.ini, respectively) in my Dropbox (~/Dropbox/config) and use symlinks to reference the shared from from the expected location. Similarly, I share a couple of code bases in the same way. The physical files are lo...

shuffle Objects php

how can i sort object in php? i tryed shuffle but that expects an array Warning: shuffle() expects parameter 1 to be array, object given in /var/www/index.php on line 366 Warning: Invalid argument supplied for foreach() in /var/www/index.php on line 334 here is the code public function updateStatusWithoutDB() { $this->upda...