Ive asked this question before, but I discovered a problem with the top answer. Its been suggested I use parse_url() to get the domain part of any URL. The problem is, the function wont work if the url doesn't start with http://
Are there any alternatives to using the parse_url function? The only I can see, is adding http:// to the url ...
I'm currently working with PHPUnit to try and develop tests alongside what I'm writing, however, I'm currently working on writing the Session Manager, and am having issues doing so...
The constructor for the Session handling class is
private function __construct()
{
if (!headers_sent())
{
session_start();
self::$session_id = sess...
Title sums it up, I know little about how I will do this.
See also:
http://stackoverflow.com/questions/120228/php-running-scheduled-jobs-cron-jobs
...
The code below crashes IE6 for some reason. Much as IE is god-awful, i have never seen this before. Does anyone have any ideas?
<div id="edit">
<?php
$a = $_POST['category'];
if ($a == "")
{
$a = $_GET['category'];
}
$result = mysql_query("SELECT * FROM media WHERE related_page_id = $a && type= 'copy'");
?>
<table width="460px;">
...
I'm looking for way to PHP to detect if a script was run from a manual invocation on a shell (me logging in and running it), or if it was run from the crontab entry.
I have various maintenance type scripts written in php that i have set to run in my crontab. Occasionally, and I need to run them manually ahead of schedule or if something...
I need to take a paragraph of text and extract from it a list of "tags". Most of this is quite straight forward. However I need some help now stemming the resulting word list to avoid duplicates. Example: Community / Communities
I've used an implementation of Porter Stemmer algorithm (I'm writing in PHP by the way):
http://tartarus.or...
I have found some libraries or web services in PHP that does the job. The problem is that the conversion is done when the page is fully loaded, I would like to convert the page to PDF after some content dynamically added via AJAX in onload event.
Thank you very much,
Omar
...
For PHP
I have a date I want line wrapped.
I have $date = '2008-09-28 9:19 pm';
I need the first space replaced with a br
to become
2008-09-28<br>9:19 pm
If it wasn't for that second space before PM, I would just str_replace() it.
...
I want to display the results of a searchquery in a website with a title and a short description. The short description should be a small part of the page which holds the searchterm. What i want to do is:
1 strip tags in page
2 find first position of seachterm
3 from that position, going back find the beginning (if there is one) of that ...
I'm using the following code to loop through a directory to print out the names of the files. However, not all of the files are displayed. I have tried using clearstatcache with no effect.
$str = '';
$ignore = array('.', '..');
$dh = @opendir( $path );
if ($dh === FALSE)
{
// error
}
$file = readdir( $dh );
while( $file !== ...
I found this:
http://www.evolt.org/failover-database-connection-with-php-mysql
and similar examples. But is there a better way?
I am thinking along the lines of the Automatic Failover Client in the MS SQL Native Client.
...
I'm looking for an easy to use, reasonably complete form validation solution for php. I recall using one years ago that used a few tags on the HMTL side then captured the OB to replace them with some pretty serious code. This feels slightly like overkill me, yet I'm not REALLY wanting to go nuts with my own right now. I'm using SMARTY...
Hi,
Why is the following code "crashing" in PHP?:
$normal_array = array();
$array_of_arrayrefs = array( &$normal_array );
end( $array_of_arrayrefs )["one"] = 1; // choking on this one
The expected result is that the final code line appends $normal_array with key "one" having value 1. In the real context of this scenario I use ...
I want to be able to do the following:
$normal_array = array();
$array_of_arrayrefs = array( &$normal_array );
// Here I want to access the $normal_array reference **as a reference**,
// but that doesn't work obviously. How to do it?
end( $array_of_arrayrefs )["one"] = 1; // choking on this one
print $normal_array["one"]; // sho...
I have an XML file loaded into a DOM document,
I wish to iterate through all 'foo' tags, getting values from every tag below it. I know I can get values via
$element = $dom->getElementsByTagName('foo')->item(0);
foreach($element->childNodes as $node){
$data[$node->nodeName] = $node->nodeValue;
}
However, what I'm trying to do, i...
We have PHP 5.2.6 deployed to c:\php and in that folder there is the php.ini file. On Windows, can a website override these settings similar to the way that apache has .htaccess? e.g.
DirectoryIndex index.php index.html
<IfModule mod_php5.c>
php_flag magic_quotes_gpc off
php_flag register_globals off
</IfModule>
<IfModule mod_php4.c>
...
When calling php via cli, the current directory is NOT changed to the one of the script. All the scripts i have running in crontab run via the CLI, so this is an issue.
I'm currently fixing the problem by doing a chdir() with the absolute path where the script is, but i REALLY dont like hardcoding paths into stuff like that.
I'm lookin...
In PHP, I am able to use a normal function as a variable without problem, but I haven't figured out how to use a static method. Am I just missing the right syntax, or is this not possible?
(EDIT: the first suggested answer does not seem to work. I've extended my example to show the errors returned.)
function foo1($a,$b) { return $a/$...
Is it possible to run both debuggers within the same PHP installation simultaneously. They both use different ports so communication with the client IDEs/other apps wouldn't be an issue.
I ask only because using the Zend Debugger with ZendStudio has proven to be much easier (fewer steps to start/stop debugging from the browser), but I r...
Hey folks - I'm not much of a coder, but I need to write a simple preg_replace statement in PHP that will help me with a wordpress plugin. Basically I need code that will search for a string, pull out the video id, and return the embed code with the video id inserted into it.
So in other words...
I'm searching for this:
[youtube=htt...