Tagged Questions

The fifth version of the PHP: Hypertext Preprocessor (PHP) scripting language. It features Zend Engine 2, better object model support and many other improvements over PHP 4.

learn more… | top users | synonyms

12
votes
1answer
7k views

how to evaluate formula passed as string in php?

Just trying to figure out the proper and safer way to execute mathematic operation passed as string. In my scenario it is values fetched from image EXIF data. After little research I found two way of ...
20
votes
10answers
2k views

Best way to access global objects (like Database or Log) from classes and scripts? [closed]

I've read some related questions (1, 2), but none seemed fully adequate. What's the best way to access globally important objects in each class or .php script? A few examples: DB (database) Cache ...
32
votes
6answers
3k views

Why do some scripts omit the closing php tag '?>'?

In some scripts I see that they omit writing a closing tag ?> for the script. I don't know why. Can someone tell me why and if I should do this as well? (I'm sure they have not forgotten it.) ...
15
votes
5answers
2k views

Are mysql_real_escape_string() and mysql_escape_string() sufficient for app security?

Will mysql_real_rescape_string() be enough to protect me from hackers and SQL attacks? Asking because I heard that these don't help against all attack vectors? Looking for the advice of experts. ...
19
votes
7answers
5k views

What factors make PHP Unicode-incompatible?

I am able use UTF-8 characters just fine in my scripts. As a matter of fact it is possible to have names of variables and functions contain Unicode characters. There is also the mb_string extension, ...
5
votes
1answer
1k views

SimpleXML Reading node with a hyphenated name

I have the following XML: <?xml version="1.0" encoding="UTF-8"?> <gnm:Workbook xmlns:gnm="http://www.gnumeric.org/v10.dtd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ...
3
votes
5answers
302 views

Official end of support for PHP4? [closed]

Is there an official date for when support for PHP4 will end? I keep reading this date and that on various sites and blogs, but can't find anything on the PHP website. Am I overlooking something?
23
votes
19answers
2k views

Is SQL injection a risk today?

I've been reading about SQL injection attacks and how to avoid them, although I can never seem to make the "awful" examples given work, e.g. this post ...
6
votes
0answers
555 views

Read a file from line X to line Y? [closed]

Possible Duplicate: How do I open a file from line X to line Y in PHP? Is there a way to read a file in PHP5 from line X to line Y into a string, without reading the entire file. I would ...
2
votes
6answers
2k views

PHP coding conventions?

Where can I find PHP coding convention references for PHP coding standards?
20
votes
8answers
4k views

How to handle user input of invalid UTF-8 characters?

I'm looking for general a strategy/advice on how to handle invalid UTF-8 input from users. Even though my webapp uses UTF-8, somehow some users enter invalid characters. This causes errors in PHP's ...
27
votes
5answers
12k views

Why does PHP 5.2+ disallow abstract static class methods?

After enabling strict warnings in PHP 5.2, I saw a load of strict standards warnings from a project that was originally written without strict warnings: Strict Standards: Static function ...
14
votes
10answers
7k views

What is a RECURSIVE Function in PHP?

Can anyone please explain a recursive function to me in PHP (without using Fibonacci) in layman language and using examples? i was looking at an example but the Fibonacci totally lost me! Thank you ...
10
votes
2answers
7k views

Zend_Form - Array based elements?

Using Zend_Form, how would I create form elements like this: <input type="text" name="element[1]" value="" /> <input type="text" name="element[2]" value="" /> // etc...
3
votes
3answers
5k views

how to go to the same page after login in PHP

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. ...
5
votes
1answer
1k views

Preserve key order (stable sort) when sorting with PHP's uasort

This question is actually inspired from another one here on SO and I wanted to expand it a bit. Having an associative array in PHP is it possible to sort its values, but where the values are equal to ...
7
votes
2answers
3k views

How to start writing a PHP5 extension in C++

I'm writing a PHP5 extension, and while I could write it in C, it would be easier to use C++ and take advantage of the STL and Boost. Trouble is, the tutorials I've seen only deal with C, and I'm ...
4
votes
2answers
22k views

File Upload using zend framework 1.7.4

I am trying to upload file using zend frame work but have not been successful. I have read Akras tutorial, which was helpful but when i used those techniques in my project I was not able to get it to ...
15
votes
2answers
393 views

Array to Object and Object to Array in PHP - interesting behaviour

Can you explain the next interesting behaviour? class test { //Class *test* has two properties, public and private. public $xpublic = 'x1'; private $xprivate = 'x2'; } $testObj = new test(); ...
11
votes
2answers
5k views

forcing access to __PHP_Incomplete_Class object properties

I'm writing a module for a php cms. In a function (a callback) I can access an object that comes from the framework code. This object is of type ' __PHP_Incomplete_Class' because the needed header ...
10
votes
3answers
980 views

unit testing and Static methods

Reading up and picking up on unit testing, trying to make sense of the following post on that explains the hardships of static function calls. I don't clearly understand this issue. I have always ...
11
votes
7answers
1k views

Does $_REQUEST have security problem?

My henchman is learning PHP currently, and he sent me his PHP code, and I found that he uses $_REQUEST in his code. The textbook I read says that $_REQUEST has security problem so we better use ...
5
votes
3answers
3k views

Why Does DOM Change Encoding?

$string = file_get_contents('http://example.com'); if ('UTF-8' === mb_detect_encoding($string)) { $dom = new DOMDocument(); // hack to preserve UTF-8 characters ...
3
votes
6answers
1k views

how to get dynamic URL like mydomain.com/username using zend framework

I am developing an application using zend framework. In the application I have to provide a URL for each user like mydomain.com/[username] then public will be able to view his profile. [username] is ...
9
votes
2answers
7k views

What is basic difference echo Vs print [closed]

Possible Duplicate: Reference: Comparing PHP's print and echo If there is any option available with one echo or print which can't be in other?
4
votes
3answers
679 views

How do I track down an “Exception thrown without a stack frame in Unknown on line 0” in PHP?

I'm working on a large (inherited) codebase in PHP, and the error Exception thrown without a stack frame in Unknown on line 0 has started showing up at the bottom of every page. I understand what the ...
0
votes
2answers
658 views

Grabbing title of a website using DOM [closed]

Possible Duplicates: Get title of website via link How do I extract title of a website? How will be a website title can be grabed using PHP DOM?? or which is the best way way to grab it ...
2
votes
3answers
2k views

How do I parse XML containing custom namespaces using SimpleXML?

I'm wondering how to parse values in XML that appear to have : in their name. I've been using: $response = file_get_contents($url); $data = simplexml_load_string($response); then doing a: ...
1
vote
4answers
1k views

Remove domain extension

So let's say I have just-a.domain.com,just-a-domain.info,just.a-domain.net how can I remove the extension .com,.net.info ... and I need the resultes in two variables one with the domain name and ...
0
votes
4answers
2k views

populate select from other select value using jquery

hi all I have seen many question but no one has fulfilled my thirst. I want to populate select on the basis of one other select. I am using zend framework. I have a select that will select a account ...
14
votes
6answers
9k views

Type casting for user defined objects

Hi Just like we do with __ToString, is there a way to define a method for casting? $obj = (MyClass) $another_class_obj;
15
votes
5answers
27k views

php_memcache.dll for PHP 5.3

I recently setup a server using the latest version of XAMPP for Windows. With it came PHP 5.3. I'm now looking for a memcache.dll file that works with PHP 5.3 I've used some of the previous .dll ...
12
votes
2answers
1k views

PHP Error handling: die() Vs trigger_error() Vs throw Exception

In regards to Error handling in PHP -- As far I know there are 3styles die()or exit() style: $con = mysql_connect("localhost","root","password"); if (!$con) { die('Could not connect: ' . ...
6
votes
2answers
4k views

SHA-512 library for PHP

I am searching for any crypto library that provides SHA-512 hash. Googling around I found some but SHA-512 is absent. Please suggest.
2
votes
2answers
11k views

How to do AES256 decryption in PHP?

I have an encrypted bit of text that I need to decrypt. It's encrypted with AES-256-CBC. I have the encrypted text, key, and iv. However, no matter what I try I just can't seem to get it to work. The ...
12
votes
3answers
13k views

How can one run multiple versions of PHP 5.x on a development LAMP server?

(Sorry for the poorly-phrased title.) I need to test my PHP applications with multiple versions of PHP 5.x, such as PHP 5.0.0 and PHP 5.2.8. Is there a way that I can configure a development LAMP ...
8
votes
3answers
1k views

Remove diacritics from a string

Is it possible? This is my input string: ľ š č ť ž ý á í é Č Á Ž Ý This is the output I want: l s c t z y a i e C A Z Y
6
votes
3answers
8k views

PHP: imagepng() and transparency

When using the function imagepng() in php, how can I make sure the images that I save are saved with a transparent background?
5
votes
2answers
2k views

Registry design pattern…good or bad?

The following code is from a tutorial (http://net.tutsplus.com/php/creating-a-php5-framework-part-1/), not mine. I have a few questions about this code... The article claims it is using the ...
9
votes
1answer
2k views

PHP5 Frameworks: Autoloading and Opcode Caching

A number of frameworks utilize spl_autoload_register() for dynamically loading classes (i.e. controllers and models). There are a couple of posts on the issue of autoloading and opcode caching. One ...
5
votes
1answer
2k views

How does PHP max_execution_time work?

I have few doubts about maximum execution time set in php.ini. Assuming max_execution_time is 3 minutes, consider the following cases: I have a process which will end in 2 minutes. But it's in a ...
5
votes
3answers
4k views

PHP Date function output in Italian

Trying to output italian dates with date: <?php setlocale(LC_ALL, 'it_IT'); echo date("D d M Y", $row['eventtime']); ?> But it's still coming out in English, any ideas of what else ...
3
votes
2answers
1k views

Allow users to download files outside webroot

Hello I am using PHP to allow users to upload files and I have them sitting in a folder outside webroot (/var/www) folder for security reasons. It is in the folder /var/uploads. A user uploads files ...
2
votes
1answer
298 views

How can I automatically create an email address for my website members?

How can I automatically create an email address for my website members and forward the mail to their own email address. eg. john123 signs up to my members site. script automatically creates email ...
2
votes
3answers
5k views

Difference between php 4 and php 5?

I'm in search of the web hosting space, and got to know the PHP version is 4.3 and MySQL Version 4.1 But i developed my application in MySQL version 5.x and PHP version 5.x Can anyone give me the ...
5
votes
2answers
674 views

Accessing private variables from within a closure

I'm trying to reference a private variable of an object from within a closure. The code below would seem to work, but it complains Fatal error: Cannot access self:: when no class scope is active in ...
3
votes
3answers
3k views

Modular web site with zend framework, stack of actions

How to build modular web site with Zend framework. I have pages in db, every page is represented as url. Every page has 1toN contents. Every content has controller, action and position (+other now not ...
0
votes
6answers
266 views

how can convert $files contain to array?

How do I solve this error? A PHP Error was encountered Severity: Warning Message: Invalid argument supplied for foreach() Filename: admin/tour.php Line Number: 81 this is line 81: $files = ...
0
votes
1answer
1k views

How to enable php extension using `phpize`?

I tried these steps on different extensions but I don't know why that doesn't work. Shouldn't I see a change in phpinfo() output after that? The steps: 1- Decompress the php source code and change ...
0
votes
2answers
3k views

PHP to MySQL SSL Connections

I have successfully setup an SSL enabled install of MySQL on one server on one network and can connect to it using SSL with the Linux command line mysql client on a different server on a different ...

1 2 3 4 5 13
15 30 50 per page