I have recently gotten involved in a project where a web-based game uses an engine written in PHP. The game works fine but could be more robust and have some more features - and the code is both old and fairly ugly.
The issue with this code (and much PHP code in general I suspect) is that it has evolved to where it is and isn't structu...
Does anybody use anything else to document their PHP code than PHPDoc?
Are there any tools that read the same documentation syntax but give richer output?
...
Does PHP have a method of having auto-generated class variables? I think I've seen something like this before but I'm not certain.
public class TestClass {
private $data = array();
public function TestClass() {
$this->data['firstValue'] = "cheese";
}
}
The $this->data array is always an associative array but they ...
I'm passing raw HTTP requests to an apache server (received by PHP). The request is of type multipart/form-data, i.e. the same MIME type used when submitting HTML forms.
However, I'm not sure what HTTP header to use for setting the form field name (I'm just assuming it's a header defining this, don't know what else it could be) which th...
Let's say I have this code:
if (md5($_POST[foo['bar']]) == $somemd5) {
doSomethingWith(md5($_POST[foo['bar']]);
}
I could shorten that down by doing:
$value = md5($_POST[foo['bar']];
if ($value) == $somemd5) {
doSomethingWith($value);
}
But is there any pre-set variable that contains the first or second condition of the current...
Take this code:
<?php
if (isset($_POST['action']) && !empty($_POST['action'])) {
$action = $_POST['action'];
}
if ($action) {
echo $action;
}
else {
echo 'No variable';
}
?>
And then access the file with ?action=test
Is there any way of preventing $action from automatically being declared by the GET? Other than of course...
This concept is a new one for me -- I first came across it at the YUI dependency configurator. Basically, instead of having multiple requests for many files, the files are chained into one http request to cut down on page load time.
Anyone know how to implement this on a LAMP stack? (I saw a similar question was asked already, but it se...
Is there a way (without installing any libraries) of validating XML using a custom DTD in PHP?
...
I wrote a small PHP application several months ago that uses the WordPress XMLRPC library to synchronize two separate WordPress blogs. I have a general "RPCRequest" function that packages the request, sends it, and returns the server response, and I have several more specific functions that customize the type of request that is sent.
I...
Hello!
What would you say is the best online-source for interesting things about PHP and stuff around it? I am thinking along the lines of a blog or online-magazine, which tells me about tricks, news and best practices.
Please add a short comment about the site you recomment! :)
Best regards, B
...
We're developing a service that will accept a POST request, and some of the POST data will need to be encypted before the POST as it will be stored in hidden fields on a form.
The application is written in C# but we want third party clients to be able to easily integrate with it. We find that most clients use PHP, Classic ASP or VB.Net....
The PHP documentation can be found here, but I think it's rather lacking. There are no examples of how to use these functions, and few (if any) of the pages have user comments. So where might I be able to find an explanation (and example code) on how to use these functions to write an XML document?
...
I have a background of Java and would like to start learning PHP. It should be interactive as in having "assignments" and problems to be solved as a part of the course and not just as a course which gives the syntax and the semantics of the language.
...
I would like to encrypt strings which could potentially only be about three or four characters but run to about twenty characters. A hashing function (md5, sha1, crypt etc) is not suitable as I would like to be able to decrypt the information as well. The mcrypt extension has a thoroughly daunting array of possibilities.
Does anyone ha...
At the beginning of each PHP page I open up the connection to MySQL, use it throughout the page and close it at the end of the page. However, I often redirect in the middle of the page to another page and so in those cases the connection does not be closed. I understand that this is not bad for performance of the web server since PHP aut...
This is written in PHP but it's really language agnostic.
try
{
try
{
$issue = new DM_Issue($core->db->escape_string($_GET['issue']));
}
catch(DM_Exception $e)
{
throw new Error_Page($tpl, ERR_NOT_FOUND, $e->getMessage());
}
}
catch(Error_Page $e)
{
die($e);
}
Is nested try, catch blocks a g...
I have:
<?php
$file=fopen(date("Y-m-d").".txt","r+") or exit("Unable to open file!");
if ($_POST["lastname"] <> "")
{
fwrite($file,$_POST["lastname"]."\n");
}
fclose($file);
?>
but it overwrites the beginning of the file. How do I make it insert?
...
For an image hosting web application:
For my stored images, is it feasible to create thumbnails on the fly using PHP (or whatever), or should I save 1 or more different sized thumbnails to disk and just load those? Please explain your reasoning.
Any help is appreciated, thanks.
...
I have noticed that cURL in PHP returns different data when told to output to a file via CURLOPT_FILE as it does when told to send the output to a string via CURLOPT_RETURNTRANSFER.
_RETURNTRANSFER seems to strip newlines and extra white space as if parsing it for display as standard HTML code. _FILE on the other hand preserves the fil...
I'm having an issue with my regex.
I want to capture <% some stuff %> and i need what's inside the <% and the %>
This regex works quite well for that.
$matches = preg_split("/<%[\s]*(.*?)[\s]*%>/i",$markup,-1,(PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE));
I also want to catch &% some stuff %> so I need to capture <% or &l...