php5

Object Oriented PHP books

Hi, I've realised just how rusty my knowledge of PHP 5 and advanced PHP programming is after completing some questions for a test. I seriously need to read a book or something. Any recommendations for PHP 5 books? ...

Cleaner way of using modulus for columns

I currently have a list (<ul>) of people that I have divided up into two columns. But after finishing the code for it I keept wondering if there is a more effective or clean way to do the same thing. echo "<table class='area_list'><tr>"; // Loop users within areas, divided up in 2 columns $count = count($areaArray); for($i=0 ; $i<$coun...

Why the following upload if condition does not work?

So I have an upload script, and I want to check the file type that is being uploaded. I only want pdf, doc, docx and text files So I have: $goodExtensions = array('.doc','.docx','.txt','.pdf', '.PDF'); $name = $_FILES['uploadFile']['name']; $extension = substr($name, strpos($name,'.'), strlen($name)-1); if(!in_array($extension,$good...

foreach loop corrupting my array?

Explanation I have a multidimensional array that is iterated over to created a categorized view of people with different research interests. The main array look something like this: Array ( ... ['Cell Biology'] => Array(4 elements) ['Molecular'] => Array(6 elements) ['Biology Education'] => Array(14 element...

Bookmarking In Joomla 1.5

Hi, i am using the Plugin Content Bookmarker downloaded from http://dev.aarthikaindia.com/downloads/category/3-plugins.html for my site. Some of the Articles are able to Bookmark like if i click on the Bookmark (twitter) , it directly bookmarks in Twitter with Some description of the Article where some of the Articles are not bookmar...

get_defined_vars() inside a class

How do i get all defined vars inside a class like if it was called outside the class scope? When i call the function inside a class method i only get an empty object. ...

PHP ORM library based on the Data Mapper pattern

For a PHP application with a complex domain model, I don't want to use the Active Record pattern, I need instead the Data Mapper pattern (as presented in Zend Framework). Do you know any library that could help me for the ORM part, or else a link to a documentation on "how to do it right" ? Thanks ...

How should i properly add key => val pair to an existing array

Tried examples from 'php.net' but don't understand what's the problem. Any suggestions ? <?php $_SESSION['test'] = array('a' => '1', 'b' => '2'); foreach ($_SESSION['test'] as $key => $val) echo "key: " . $key . " val: " . $val . "\n"; // Parse error array_push($_SESSION['test']['c'] => '3'); // Parse error $_SESSION['test'][] ...

Does anyone knows a web application security scanner for mac?

Does anyone knows a web application security scanner for mac and easy to install? ...

8 byte Integer with Doctrine and PHP

Hi, the players: 64bit linux with php 5 (ZendFramework 1.10.2) PostgreSQL 8.3 Doctrine 1.2 Via a Flash/Flex client i get an 8byte integer value. the field in the database is an BIGINT (8 byte) PHP_INT_SIZE show that system supports 8byte integer. printing out the value in the code as it is and as intval() leads to this...

Why not to use Array of errors instead of Exception Handling !?

Why not using array of errors instead of throwing errors and check if it's not empty later in the code.... Exception handling is very confusing to me , I can not understand it's purpose ... can anybody enlighten me !? they compare it with die() as better not to stop the execution of the code , why would I stop the execution of code if ...

PHP SOAP error: Method element needs to belong to the namespace

I'm unable to retrieve data from an XML document, any help is greatly appreciated. I'm using PHP 5.2.10 and the WSDL url is an internal link within my company. The following code produces an error. $url = "http://dta-info/IVR/IVRINFO?WSDL"; $params = array("zANI" => "12345"); try{ $client = new SoapClient($url, arra...

Regular Expressions: RegEx for determining valid PHP class property names?

I am using PHP's magic __set and __get methods to access a private array in a class. Use of the class can include "setting" new properties as well as using existing ones. I want to make sure the property names created or requested (i.e. $myObj->FakeProperty) are valid according to the following rules: Property names must begin with eit...

Does somebody have a working sample of PHP session_set_save_handler ?

PHP Version 5.1.6 All day trying..I'm breaking my head now... I understand it but can't make it work. I need to store the session data in a mysql database, cause we're balancing the request among 2 servers, so regular sessions wont work... I need to use this function ... session_set_save_handler ... and I cant make it work..any help grea...

Application Errors vs User Errors in PHP

So after much debate back and forth, I've come up with what I think may be a valid plan to handle Application/System errors vs User Errors (I.e. Validation Issues, Permission Issues etc). Application/System Errors will be handled using a custom error handler (via set_error_handler()). Depending on the severity of the error, the user may...

Check whether the string is a unix timestamp

I have a string and I need to find out whether it is a unix timestamp or not, how can I do that effectively? I found this thread via Google, but it doesn't come up with a very solid answer, I'm afraid. (And yes, I cribbed the question from the original poster on the aforementioned thread). ...

$_SERVER['PHP_AUTH_PW'] not getting set when using a specific Apache location

So I noticed some odd behavior with Apache today. It appears that when I change my location from "/" to "/somedir" that PHP does not properly set the $_SERVER['PHP_AUTH_PW'] variable. I am not sure why this is happening nor do I know where to go to see why it could not be getting set. I am using PHP5 and Apache2 with LDAP as my authenti...

Accumulate 2D Array by Index

I have an array that looks like this: Array ( [0] => Array ( [amount] => 60.00 [store_id] => 1 ) [1] => Array ( [amount] => 40.00 [store_id] => 1 ) [2] => Array ( [amount] => 10.00 [store_id] => 2 ) ) W...

How do I upgrade PHP in Mac OS X?

I feel this is an awfully obtuse question to ask, but strangely, this problem is poorly documented. I would like to upgrade PHP, but there are several problems: There is no built-in package manager. MacPorts doesn't recognize php as an installed package because it didn't install PHP itself. Running locate php indicates there are pro...

how to go to the same page after login in PHP

Hi all, For example, STEP 1: I am browsing a page without logging in and my last page before logging in is beforeLogin.php STEP 2: Now my prob is when i logged in i am redirecting to the index.php page. Instead i should be redirected to the last page what i had browsed. That is from the above example is should redirected to befor...