php

How can I determine a file's true extension/type programatically?

Hey everyone, I am working on a script that will process user uploads to the server, and as an added layer of security I'd like to know: Is there a way to detect a file's true extension/file type, and ensure that it is not another file type masked with a different extension? Is there a byte stamp or some unique identifier for each typ...

PHP based form validation helpers?

From my time working with Ruby On rails, there is a couple different packaged/projects out there to manage both validation and error reporting in an extensible way. Self-studying Python Pylons I just got introduced to HTMLFill which so far seems like an elegant solution to a common task of form validation. I know both examples are feat...

Using __call with static classes?

Is it possible to use the __call magic method when calling functions statically? ...

Is there a performance benefit single quote vs double quote in php?

Are there any performance benefits to using single quotes instead of double quotes in php? In other words, would there be a performance benefit of: $foo = 'Test'; versus $foo = "Test"; G-Man ...

As a PHP developer thinking of making Perl a secondary strong suit, what do I need to know?

I consider myself quite fluent in PHP and am rather familiar with nearly all of the important aspects and uses, as well as its pratfalls. This in mind, I think the major problem in taking on Perl is going to be with the syntax. Aside from this (a minor hindrance, really, as I'm rather sold on the fact that Perl's is far more readable), w...

PHP Errors on Making Local Copy of Server

I have a site that I am trying to create a local copy of for test purposes (dusting off a past site). I was able to correctly get the db out and most of the site works great. However, I have places where things aren't loading correctly and are just giving me errors or messages in curly braces. For example, a td class' name is being re...

preg_match works in regexbuddy, not in php

Ok so I have this regex that I created and it works fine in RegexBuddy but not when I load it into php. Below is an example of it. Using RegexBuddy I can get it to works with this: \[code\](.*)\[/code\] And checking the dot matches newline, I added the case insensitive, but it works that way as well. Here is the php: $q = "[code]<d...

php readdir problem with japanese language file name

Hello, I have the following code <?php if ($handle = opendir('C:/xampp/htdocs/movies')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo $file."<br />\n"; } } closedir($handle); } ?> When it does have mb language such as japanese, it doesn't display pro...

PHP regex delimiter, what's the point?

Why do PHP regexes have the surrounding delimiters? It seems like it would be more clear if any pattern modifiers were passed in as a parameter to whatever function was being used. ...

Apache alternatives to PHP header function.

I'm working on a website that has a number of style sheets all of which need to be handled as php scripts server-side. My .htaccess file looks something like this: <FilesMatch "\.(css)$"> ForceType application/x-httpd-php </FilesMatch> This causes a small problem as the mime type of the http-response's Content-Type field is then s...

What is the CS definition of a Php Array?

From a strictly implementation and computer science point of view how would you classify the Php array datastructure? Is it an associative array? a hash? a dictionary? ... ? ...

Chaining a constructor with an object function call in PHP

Does anyone know if the following expression will be possible in the next version(s) of PHP? (new A())->a(); // Causes a syntax error I find very annoying that currently one must write 2 lines instead of 1: $c = new A(); $c->a(); ...

Flash+PHP+cookie

I want an animation play only once in the browser. If any user seen the movie and if goes to any other page or refresh(F5) and then come back on the animation page then animation should not play from start. I want to play it from another frame. I think it can be done by set cookie or somthing using javascript or php. Please anybody he...

Preforming math stored in variables

I have 3 variables like this: $first = 2; $second = 5; $operation = '*'; how can I programaticly assign the solution to this math problem to the $answer variable? I have tried eval(), but that does not work. ...

Running PHP pages in DNN 4.X

Hi, I am having some PHP pages in a DNN 4 site.But when I try to browse these pages in the internet browser with the site url folowed by the directory and location of the php pages, I get a page not found error. Although all these pages are working fine for a DNN 3 instance on the same server.The only basic difference I can find between...

What's the best way to supply download of a digital product in PHP?

Digital commercial products that customers pay for download link. I have put all the zipped files (products) outside of web document root and buyers download them via a php script which is integrated with paypal IPN to make sure the downloader is a paying buyer. Sort of like: http://www.mysite.com/download.php?buyer_id=xxx Thus far i...

php .tpl based content management system — pros and cons

Hello, I work at a company which uses a legacy content management system based on php utilizing templates. I am fed up with it as it is vastly inferior to modern CMS' (i.e. Drupal), particularly due to poor AJAX implementation capability and general confusion of branched out template tree. It is within my power to switch to a newer CMS ...

Ie8 doesn't pass session cookie for ajax request

I have simple php application, it works on all browsers except on IE8 beta 2, problem occurs when I try to update table field using Ajax call (jQuery post method). Using IE8 debugger I figure out that IE8 doesn't send session cookie so php scripts redirects to login page instead of executing requested action. What can I do to make this...

Trimming or converting a mysql date field with php

Hello, I am displaying the contents of a datetime field in mysql in a table with php, and want to show just the date. Is there a way to convert or do this, or must the actual string be editied or trimmed? ...

Getting the Wordpress Rss file

I'm running a wordpress blog and would like to access the actual file that creates the feed. Unfortunately when I do that it throws up a lot of errors because it's using a lot of functions. My current best idea is to make a duplicate file that doesn't need those functions or has them hard coded in but I want to get a 2nd opinion on this...