To create a PHP program that prints a marksheet, you can start by defining an associative array to store subjects and their corresponding marks. Use a loop to iterate through the array and calculate total marks and percentage. Finally, format the output using HTML for better presentation, and utilize the echo
statement to display the marksheet. Here’s a simple example:
<?php
$marks = ["Math" => 85, "Science" => 78, "English" => 92];
$total = array_sum($marks);
$percentage = ($total / (count($marks) * 100)) * 100;
echo "<h1>Marksheet</h1>";
foreach ($marks as $subject => $mark) {
echo "$subject: $mark<br>";
}
echo "Total: $total<br>";
echo "Percentage: $percentage%";
?>
Try the triangle program on a search engine. Replace numbers with stars and that should do the trick
Code Below: <?php $j = 100; // Set limit upper limit echo "Even Numbers are: <br/>"; for($i=1;$i<=$j;$i++) { if($i%2) { continue; } else { echo $i."<br/>"; } } ?>
You can do this: <?php if ( $word === strrev( $word ) ) { echo "The word is a palindrome"; } else { echo "The word is not a palindrome"; }
To print a particular value in PHP you have to select which variable you wish to print. Below is an example of how this can be done. <?php $var[1] = "Hello"; $var[2] = "Lalala"; print $var[2]; // prints Lalala but not Hello ?>
There are several different ways to output text on the screen in PHP two of the most common are echo and print. echo "Hello World!"; print ("Hello World!"); Would both print ... Hello World!
echo or print < both of which write text: <?php echo "TEXT"; print "TEXT"; ?>
// example of 1..12x12 table for($i = 1; $i <= 12; $i++) { for($j = 1; $j <= 12; $j++) { print ($i * $j) ." "; } print "\n"; }
Try the triangle program on a search engine. Replace numbers with stars and that should do the trick
Code Below: <?php $j = 100; // Set limit upper limit echo "Even Numbers are: <br/>"; for($i=1;$i<=$j;$i++) { if($i%2) { continue; } else { echo $i."<br/>"; } } ?>
It is really simple to print an HTML table in PHP, all you have to do is the following: <?php print "<table>"; print "<tr>"; print "<td>hello</td>"; print "</tr>"; print "</table>"; ?>
well, as such there is no Widget in php. You need to write your own widget program if you are interested to develop. You must be aware of wordpress built on php plateform and that uses widget extensively :)
You can do this: <?php if ( $word === strrev( $word ) ) { echo "The word is a palindrome"; } else { echo "The word is not a palindrome"; }
To print a particular value in PHP you have to select which variable you wish to print. Below is an example of how this can be done. <?php $var[1] = "Hello"; $var[2] = "Lalala"; print $var[2]; // prints Lalala but not Hello ?>
<pre> <?php $limit = 100; $primeList = array(); for($i = 2; $i < round(sqrt($limit)); $i++) { foreach($primeList as $num) { if($i%$num 0)) continue 2; } $prime[] = $i; } print_r($prime); ?> </pre> Based on Sieve of Erathosthenes. See the related link for further information.
Ratinonal program in php
$n = 10*(1+10)/2;
We can write php extension is many way... .php , .php5, .php4