Posts

Showing posts from September, 2024

Layers

  <!DOCTYPE html> <html> <head>     <title>Stack Ordering</title>     <style type="text/css">         #layer1 {             border: solid thick black;             background-color: brown;             padding: 10px;             width: 300px;             height: 200px;             position: absolute;             top: 100px;             left: 200px;             z-index: 1;         }         #layer2 {             border: solid thick black;             background-color: gray;             padding: 10px;     ...

Text growing and shrinking

  <!DOCTYPE html> <html> <body>     <div id="h"></div>     <script>         var v = 0, f = 1, t = "TEXT-GROWING", color;         function a() {             if (f == 1) {                 v += 5;                 color = "red";             } else {                 v -= 5;                 color = "blue";             }             document.getElementById("h").innerHTML =                  "<h1 style='font-size:" + v + "px;color:" + color + ";'><b>" + t + "</b></h1>";             if (v >= 50) {       ...

Squares and cubes

  <!DOCTYPE HTML> <html> <head>      <style>         table, tr, td {             border: solid black;             width: 33%;             text-align: center;             border-collapse: collapse;             background-color: lightblue;         }         table {              margin: auto;         }      </style>     <script>         document.write("<table><tr><th colspan='3'>NUMBERS FROM 0 TO 10 WITH THEIR SQUARES AND CUBES</th></tr>");         document.write("<tr><td>Number</td><td>Square</td><td>Cube</td></tr>");     ...

Prime number

 <?php $number=1; while($number<50) {  $div_count=0;  for($i=1;$i<$number;$i++)  {    if(($number%$i)==0)   {    $div_count++;   }  }   if($div_count<=2)  {   echo $number." ,";   }  $number++; } ?>

Merge array

 <?php $f_array=array(25,4,56,35,25,85); $s_array=array(48,735,52,39); echo "Elements of array are:<br>"; for ($i=0;$i<count($f_array);$i++) {   echo $f_array[$i].","; } for ($i=0;$i<count($s_array);$i++) {   echo $s_array[$i].","; } $merge_array=array_merge($f_array,$s_array); echo"<br>Elements of merged array before sorting are:<br>"; for($i=0;$i<count($merge_array);$i++) {    echo $merge_array[$i].","; } rsort($merge_array); echo"<br> Elements of merged array after sorting are <br>"; for($i=0;$i<count($merge_array);$i++) {    echo $merge_array[$i].","; } ?>

Files

 <?php $fname="file1.txt"; $fptr=fopen($fname,"r"); $content=fread($fptr,filesize($fname)); $fptw=fopen("file2.txt","w"); fwrite($fptw,$content); echo"<strong>the content copied in file2 is:</strong> <br>".$content; fclose($fptr); fclose($fptw); ?>

String

 <?php $mystr="php is a server side scripting language"; echo "<strong> the given string is :</strong> $mystr <br>"; echo "<strong> the length of string is :</strong>".strlen($mystr)."<br>"; echo "<strong> the count of string is :</strong>".str_word_count($mystr)."<br>"; echo "<strong> the reverse of string is :</strong>".strrev($mystr)."<br>"; $substr="side"; echo "<strong> the position of string is '$substr' in the string is :</strong>".strpos($mystr,$substr);

Simple calculator

 <html> <body>         <div align="center">         <h2>SIMPLE CALCULATOR</h2>         <script type="text/javascript">             a = ['1','2','3','+','4','5','6','-','7','8','9','*','C','0','=','/']             z = '<td> <input type="button" value="'             document.write('<form name="cal"><table><tr><td colspan="8"> <input type="text" name="get"></td></tr><tr>');             for (var i = 0; i<16; i++)              {                 if(i==12)                 {                     document.write('<td> <input type="reset" value="C" ...