rand function rol dicer game
|
|
$rand = rand();
|
|
echo '<h2> .' $rand '. </h2>'
|
some random numbr
|
$max =getrandmax();
|
1234567890
|
echo $max;
|
2147483647
|
<?php
|
The isset()
function checks whether a variable is set, which means that it has to be
declared and is not NULL.
|
if (isset($_POST['roll'])) {
|
whenever roll name is post, if it is post means it is true,
isset of true, it go to next statmentent
|
$rand = rand();
|
some value will go to random variable
|
echo '<h2> you got: '. $rand .'</h2>';
|
it will print that value
|
}
|
This function
returns true if the variable exists and is not NULL, otherwise it returns
false.
|
?>
|
|
<form action = "index.php"
method="POST">
|
method post, whenever u click submit button, that name post or
sent to index.php, that name script will execute
|
<input type="submit" name="roll"
value="Roll dice">
|
|
</form>
|
|
$rand = rand(1, 10);
|
it will give from 1 to 10
|
server variables - predeffined variables
|
|
index.php
|
|
echo $_SERVER['SCRIPT_NAME'];
|
$_SERVER - IS a variable which can print the file name by calll
script_name
|
forminc.php
|
|
<form action="index.php"
method="post">
|
|
<input type="submit" name="submit"
value="submit">
|
whenever u submit , it will post that name to index page
|
</form>
|
|
page1
|
|
<?php
|
|
include <forminc.php':
|
without writing the whole code, u can include that. It wil
automatically display forminc code, whenever u clik on submit, it page
redirects to index page
|
?>
|
|
page2
|
|
<?php
|
|
include <forminc.php':
|
|
?>
|
|
index.php
|
|
<?php
|
|
include 'forminc.php';
|
|
if (isset($_POST['submit'])){
|
|
echo 'clicked on index page';
|
if u submit from any page it print same data, clicked on index
page
|
}
|
|
?>
|
|
I want page name print on what they have
|
|
forminc.php
|
|
<?php
|
|
$sName = $_SERVER['SCRIPT_NAME'];
|
|
?>
|
defailt template
|
<form action="<? Php echo $sName ?>"
method="post">
|
whenever u click , on submit, it will post to same page , in
that it will print that php script after the submit button
|
<input type="submit" name="submit"
value="submit">
|
it will not redirects and
it will redirects to same page
|
</form>
|
|
page1
|
|
<?php
|
if u clicked on page 1, it will print click on page1, previously
itwill redirect ot index , but it will not because we given actiion is this
page url, so it will redirects and post to that page only
|
include <forminc.php':
|
|
?>
|
|
page2
|
|
<?php
|
|
include <forminc.php':
|
|
?>
|
|
echo $_SERVER['HTTP_HOST'];
|
PRINT THE DOMAIN NAME OR LOCAL HOST
|
Create a confic.php
|
|
<?php
|
|
$host = $_SERVER['HTTP_HOST'];
|
|
$images = 'http://'.$host.'/telugucomputerword/images/';
|
in host it will print server name
|
?>
|
|
index.php
|
|
<h1> index page <?h1>
|
|
<?php
|
|
require 'confinc.php';
|
call that confinc file to use some variable
|
echo <img src=" '.$images. 'sweety.jpg" />';
|
it prints image using indirect method
|
?>
|
|
| rand |
| getrandmax() |
| isset |
| rand(1,10) |
| $_SERVER |
| forminc.ph |
| template |
| form page |
| include |
| include |
| include |
| isset |
| $_SERVER['SCRIPT_NAME']; |
| action is same page url |
| templat used |
| include |
| $_SERVER['HTTP_HOST']; |
| $_SERVER['HTTP_HOST']; |
| require |
| concatenate image url |
| how to print any random number | ||||||||||||||||||||||||||||||||||||||||||||||||
| how to print the maximum random number | ||||||||||||||||||||||||||||||||||||||||||||||||
| how to execute if it is true | ||||||||||||||||||||||||||||||||||||||||||||||||
| how to submit to some php page with some name | ||||||||||||||||||||||||||||||||||||||||||||||||
| how to print the page file name | ||||||||||||||||||||||||||||||||||||||||||||||||
| what post does and if action is some page url, will it redirects to that page | ||||||||||||||||||||||||||||||||||||||||||||||||
| is it take name value to cross check in server after submit? | ||||||||||||||||||||||||||||||||||||||||||||||||
| what happened after submit | ||||||||||||||||||||||||||||||||||||||||||||||||
| what is maeant by template | ||||||||||||||||||||||||||||||||||||||||||||||||
| will we use other page script without writing total | ||||||||||||||||||||||||||||||||||||||||||||||||
| save time code | ||||||||||||||||||||||||||||||||||||||||||||||||
| is it change in all page if we change in a one page | ||||||||||||||||||||||||||||||||||||||||||||||||
| isset , what Is it means, is it execute whenerver argument output is true | ||||||||||||||||||||||||||||||||||||||||||||||||
| whwnever argument Is true, it wil go to inside | ||||||||||||||||||||||||||||||||||||||||||||||||
| how can we print thepage name | ||||||||||||||||||||||||||||||||||||||||||||||||
| canwe write script in action instead direct url | ||||||||||||||||||||||||||||||||||||||||||||||||
| what happen if we click on submit button, | ||||||||||||||||||||||||||||||||||||||||||||||||
| wil it print the data in template after refresh | ||||||||||||||||||||||||||||||||||||||||||||||||
| wil it print same page name | ||||||||||||||||||||||||||||||||||||||||||||||||
| how can we print the host name | ||||||||||||||||||||||||||||||||||||||||||||||||
| $ means it is called predefined variables in server terms | ||||||||||||||||||||||||||||||||||||||||||||||||
| how to create a temple which can be used in so many pages without writing total code | ||||||||||||||||||||||||||||||||||||||||||||||||
| how can I print the iamge without writing total image url | ||||||||||||||||||||||||||||||||||||||||||||||||
| how to some output fromtemplate | ||||||||||||||||||||||||||||||||||||||||||||||||
| how to use some output from another php page,using this how to printthe image | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
No comments:
Post a Comment