I have noticed that regardless of a given script's execution time, every date() call will return the same timestamp regardless of where the function is called within the script. It looks like it just returns the time at which the script first started executing.
For logging purposes, it would be extremely useful to be able to get increme...
I'm wondering if PHP has this optimization built in. Normally when you call foreach without using a reference it copies the passed array and operates on it. What happens if the reference count to that array is only 1?
Say for example if getData returns some array of data.
foreach(getData() as $data)
echo $data;
Since the array ...
The first one is definitely something that works, but which one below is the efficient way?
switch($type) {
case 1:
print 'success';
break;
case 2:
print 'success';
break;
case 3:
print 'success';
break;
case 4:
print 'success for type 4';
break;
}
Since 1, 2 and 3 print do the sa...
I am trying to include a value from a database table within the value element of an input field.
This is what I have, but it is not working
?><input type="text" size="10" value="<?=date("Y-m-d",
strtotime($rowupd['upcoming_event_featured_date']))?>" name="upcoming_event_featured_date"
id="keys"/><?php
I have done this before, but I...
Is there any library function for this purpose, so I don't do it by hand and risk ending in TDWTF?
echo ceil(31497230840470473074370324734723042.6);
// Expected result
31497230840470473074370324734723043
// Prints
<garbage>
...
include('adodb5/adodb.inc.php');
$myServer = "localhost";
$myUser = "root";
$myPass = "root";
$myDB = "database";
//create an instance of the ADO connection object
$conn = new COM("ADODB.Connection") or die("Cannot start ADO");
//define connection string, specify database driver
$connStr = "PROVIDER=SQLOLEDB;SERVER=...
I want to use the php simple HTML DOM parser to grab the image, title, date, and description from each article on a page full of articles. When looking at the API I notice it has a set_callback which Sets a callback function. However im not sure what this does or how I would use it? In one of the examples its used to call a function whic...
I'm using NuSOAP on PHP 5.2.6 and I'm seeing that the max message size is only 1000 bytes (which makes it tough to do anything meaningful). Is this set in the endpoint's WSDL or is this something I can configure in NuSOAP?
...
Hi,
I am currently building a small website where the content of the main div is being filled through an Ajax call. I basically have a php script that returns the content like this:
(simplified php script...)
if(isset($_POST["id_tuto"])){
PrintHtml($_POST["id_tuto"]);
}
function PrintHtml($id)
{
switch($id)
{
case [...]:
...
I need to match (case insensitive) "abcd" and an optional trademark symbol
Regex: "/abcd(™)?/gi"
See example:
<?php
preg_match("/abcd(™)?/gi","AbCd™ U9+",$matches);
print_r($matches);?>
When I run this $matches isn't populated with anything... not even created as an empty array. Any ideas?
Thanks.
...
We have a large management software that is producing big reports of all kinds, based on numerous loops, with database retrievals, objects creations (many), and so on.
On PHP4 it could run happily with a memory limit of 64 MB - now we have moved it on a new server and with the same database - same code, the same reports won't come up wi...
My crappy web host did some upgrades the other day and some settings have gone awry, because looking at our company's wiki (MediaWiki), every quote is being escaped with a backslashes. It's not even just data which is being posted (ie: the articles) which are affected, but also the standard MediaWiki text. eg:
You\'ve followed a link...
I have a volunteers_2009 table that lists all the volunteers and a venues table that lists the venues that a volunteer can be assigned to, they are only assigned to one.
What I want to do, is print out the number of volunteers assigned to each venue.
I want it to print out like this:
Name of Venue: # of volunteers
table: volunteers_2...
I plan on using MySQL and it's built-in encryption functionality to encrypt / decrypt certain columns in certain tables. The concern I have is that I need to store the key somewhere. I could certainly store the key in a file and control the permissions of that file and the permissions of the application that accesses it, but is that en...
I'm building a webpage that queries a MySQL database and (currently) produces a text-only list of the findings. The queries to complete a single record are similar to:
movie (title, description, etc)
actors in the movie (name, gender)
related movies
Out of curiosity I've used memory_get_peak_usage() and memory_get_usage():
start ...
Hey!
Has anybody used a good obfuscator for PHP?, I've tried some but they dont work for very big projects. They can't handle variables that are included in one file and used in another, for instance.
Or do you have any other tricks for stopping the spread of your great code? :)
...
Hod do I multiply the values of a multi-dimensional array with weigths and sum up the results into a new array in PHP or in general?
The boring way looks like this:
$weights = array(0.25, 0.4, 0.2, 0.15);
$values = array
(
array(5,10,15),
array(20,25,30),
array(35,40,45),
...
What are the worst practices found in PHP code?
Some examples:
Use of $array[reference] without single quotes
Instance "hidden" variables into inclusion files, which are needed later
Lots of recursive inclusion not using "_once" functions
Note: maybe subjective or "fun" if you like.
...
Hi,
I'm starting a Wordpress Blog that will have adult content on it, so I'll need a first-time-only splash page in Wordpress. The first-time-only issue, I can fix with a cookie (although I am aware that not everyone has cookies enabled)
What I could do is, create a script that loads another page if a cookie isn't present. Or I could ...
Hello All,
I'm looking to setup a lightweight, developer only web stack on Windows (and possible OSX). Ideally, I'd be working with Zend framework, MySQL. But I'm open to other APIs to facilitate creating RESTFul (or pseudo-Restful) web services.
I've seen some tools, like QuickPHP, but it might have been too lightweight as I could...