I'm trying out PHPTAL and I want to render a table with zebra stripes. I'm looping through a simple php assoc array ($_SERVER).
Note that I don't want to use jQuery or anything like that, I'm trying to learn PHPTAL usage!
Currently I have it working like this (too verbose for my liking):
<tr tal:repeat="item server">
<td tal:conditi...
I'm trying to learn more about MVC but I would really like some examples I can play with and modify to help learn the concepts and my language of choice is PHP.
Books/websites are preferred, thanks!
EDIT: I didn't really want to use a framework...
...
Sounds easy, but I can't find where this built in class and others exists in the documentation. I use functions but want to know what there is on the OO side.
...
Hi all. I'm adding avatars to a forum engine I'm designing, and I'm debating whether to do something simple (forum image is named .png) and use PHP to check if the file exists before displaying it, or to do something a bit more complicated (but not much) and use a database field to contain the name of the image to show.
I'd much rather ...
I had this question earlier and it was concluded it was a bug in 5.2.5. Well, it's still broken in 5.2.6, at least for me:
Please let me know if it is broken or works for you:
$obj = new stdClass();
$obj->{"foo"} = "bar";
$obj->{"0"} = "zero";
$arr = (array)$obj;
//foo -- bar
//0 -- {error: undefined index}
foreach ($arr as $key=>...
Hi,
Very simple question: how can I access the apache basic-auth username in a PHP script? I remember having done this once before, but I can't remember how.
Thanks,
Ben
...
Is there a list describing all of the data_type parameters you can use in PDOStatement::bindParam() ? If none, what do you commonly use, and for what type of field ?
According to PHP manual: *data_type* Explicit data type for the parameter using the PDO::PARAM_* constants.
I know about the PDO::PARAM_INT and PDO::PARAM_STR . I've hear...
I am developing an application and want to display a form that will be filled in if editing the form, but will not be if the form will be a new entry. I believe the least verbose way of doing this is to have just one form and to suppress any errors for echoing my variables so that nothing will be printed if it is a new form (since the v...
So far i have got the code below which works lovely when trying an update, delete or select statement. However I run into problems when I try to use an insert. If someone could point me in the correct direction i would be grateful.
private function escape($value)
{
if(get_magic_quotes_gpc())
$value = stripslashes($value);
...
For our school project, we are tasked to define a design document describing the architecture of a PHP application.
We are free te decide what to include in the document.
Our professor suggested, lots of (UML) diagrams.
He also asked us to consider class diagrams, but with care, as PHP is not fully object oriented.
My question: Is a...
On some websites or forums I usually go to, entries that I havn't read yet are marked as "new". I would like to implement this feature on a website I have developed (with news being posted from time to time) -- php/mySQL. How is this usually done ? Does it require using a cookie remembering the last visit date/time ? Or the last viewed p...
I am using NetBeans for PHP 6.5.
In my code I frequently use the following type of command:
if (($row = $db->get_row($sql))) {
return $row->folder;
} else {
return FALSE;
}
Netbeans tells me that I should not be using assignments in the IF statement.
Why ?
...
I am looking for a way to pull the first 100 characters from a string variable to put in another variable for printing.
Is there a function that can do this easily?
For example:
$string1 = "I am looking for a way to pull the first 100 characters from a string variable to put in another variable for printing.";
$string2 = 100charfunc...
I'm writing a simple application in PHP which needs to occasionally carry out a fairly intensive set of MySQL updates. I don't particularly want this to cause a delay for the user, so I'm wondering about using pcntl_fork().
I'm not sure how this really works though: will the child process continue running after the parent process finis...
Is there some equivalent of "friend" or "internal" in php? If not, is there any pattern to follow to achieve this behavior?
Edit:
Sorry, but standard Php isn't what I'm looking for. I'm looking for something along the lines of what ringmaster did.
I have classes which are doing C-style system calls on the back end and the juggling has...
I need to be able to see if a form input in PHP is numeric. If it is not numeric, the website should redirect. I have tried is_numeric() but it does not seem to work.
Code examples will be nice.
I am developing a shopping cart that accepts an interger value for the quantity. I am trying this:
if(!is_numeric($quantity)){
...
I know this is usually done with cookies, but I am getting unpredictable results on different browsers and decided to look for a pear package that focuses on this. Just wondering if there's a package (HTTP_Client for example?) that anyone has had success using for this particular situation. Or actually, do people never or rarely have p...
Is there a full featured, job scheduling package available for PHP? I'm looking for the PHP equivalent to Java's Quartz. I'm fine having things triggered externally from cron to drive the system. The functionality I'd be looking for:
Ability to register task (class/method) to be called at given intervals.
Ability to specify whether a g...
How do you build a hierarchical set of tags with data in PHP?
For example, a nested list:
<div>
<ul>
<li>foo
</li>
<li>bar
<ul>
<li>sub-bar
</li>
</ul>
</li>
</ul>
</div>
This would be build from flat data like this:
nested_array = array(...
I have a site that enables users to upload images which are then re-sized into 4 different sizes.
I'm moving to a new host and I wondered what makes a good spec for handling this task - or should any server spec be able to handle this task. Should I look at more RAM or a better CPU etc...
Images are currently restricted to 2mb but I'd ...