htpasswd for particular folder

AuthUserFile d:/xampp/htdocs/.htpasswd
AuthGroupFile /
AuthName "Restricted Access"
AuthType Basic
<limit GET>
 require valid-user
</Limit>

Split Example in PHP

<?
$str="sasikumar123inia567medical456";
$split1=split('[0-9]',$str);
echo "<pre>";
print_r($split1);
echo "</pre>";
?>


Curent time-15 minits

<?
echo time();
echo "<br>";
echo $timerange =time()-900; //20 minutes from now
?>

php Subtract the Time

<?php

function subtractTime($hours=0, $minutes=0, $seconds=0, $months=0, $days=0, $years=0)

{

$totalHours = date("H") - $hours;

$totalMinutes = date("i") - $minutes;

$totalSeconds = date("s") - $seconds;

$totalMonths = date("m") - $months;

$totalDays = date("d") - $days;

$totalYears = date("Y") - $years;

$timeStamp = mktime($totalHours, $totalMinutes, $totalSeconds, $totalMonths, $totalDays, $totalYears);

$myTime = date("Y-m-d H:i:s A", $timeStamp);

return $myTime;

}

// Let us first see the current time

echo "Current Time:"  . date("Y-m-d H:i:s A");

echo "<BR>";

// Now let us deduct 5 hours, 2 days and 1 year from now

echo "New Time: " .subtractTime(0,15,0,2,0,0);

?>

Substring function in php

<?php
header ('Content-type: text/html; charset=utf-8');
echo $haystack = 'Iñtërnâtiônàlizætiøn';
 
$substr = substr($haystack, 0, 13); // Position 13 is in the middle of the ô char
 
print "Substr: $substr<br>";
?>

Remove White Spaces using php

<?php
//The hex codes are space, tab, line feed, vertical tab, form feed, carriage return
 $whitespace ="";
 $teststring = "Charit&#x00E9;-Universit&#x00E4;; " ;
// $result = ereg ("[[:space:]]&([#]?[a-zA-Z0-9]*)?;", $teststring);
$teststring =ereg_replace("[[:space:]]\&([#]?[a-zA-Z0-9]*)?;","&#160;\\0", $teststring);
echo $teststring;
//Prints Matches 11 characters
?>

Open new window

<html>
<head>
<script type="text/javascript">
function open_win() {
    window.open("http://www.java2s.com/")
    window.open("http://www.java2s.com/")
    window.open("http://www.java2s.com/")
    window.open("http://www.java2s.com/")
}
</script>
</head>

<body>
<form>
<input type=button value="Open Windows" onclick="open_win()">
</form>
</body>

</html>

php simple xml read

<?
if (!$myxml=simplexml_load_file('process.xml')){

    echo 'Error reading the XML file';

    }
        echo $chaptername=$myxml->chapterid->name;
        echo "<br>";
       
    foreach($myxml->table as $movie){

        echo 'name: ' . $movie . '<br />';   

       

    }

?>


php yesterday date format

<?php
$m=date('m');
$d=date('d');
$y=date('Y');
echo $todaydate=date('Y-m-d');
$yday=date("Y-m-d", mktime(0, 0, 0,$m,$d-1,$y));
echo "<br>";
echo $yday;
?>