Tuesday, 9 June 2020

rand function rol dicer game

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
$_SERVER['PHP_SELF'] Returns the filename of the currently executing script
$_SERVER['GATEWAY_INTERFACE'] Returns the version of the Common Gateway Interface (CGI) the server is using
$_SERVER['SERVER_ADDR'] Returns the IP address of the host server
$_SERVER['SERVER_NAME'] Returns the name of the host server (such as www.w3schools.com)
$_SERVER['SERVER_SOFTWARE'] Returns the server identification string (such as Apache/2.2.24)
$_SERVER['SERVER_PROTOCOL'] Returns the name and revision of the information protocol (such as HTTP/1.1)
$_SERVER['REQUEST_METHOD'] Returns the request method used to access the page (such as POST)
$_SERVER['REQUEST_TIME'] Returns the timestamp of the start of the request (such as 1377687496)
$_SERVER['QUERY_STRING'] Returns the query string if the page is accessed via a query string
$_SERVER['HTTP_ACCEPT'] Returns the Accept header from the current request
$_SERVER['HTTP_ACCEPT_CHARSET'] Returns the Accept_Charset header from the current request (such as utf-8,ISO-8859-1)
$_SERVER['HTTP_HOST'] Returns the Host header from the current request
$_SERVER['HTTP_REFERER'] Returns the complete URL of the current page (not reliable because not all user-agents support it)
$_SERVER['HTTPS'] Is the script queried through a secure HTTP protocol
$_SERVER['REMOTE_ADDR'] Returns the IP address from where the user is viewing the current page
$_SERVER['REMOTE_HOST'] Returns the Host name from where the user is viewing the current page
$_SERVER['REMOTE_PORT'] Returns the port being used on the user's machine to communicate with the web server
$_SERVER['SCRIPT_FILENAME'] Returns the absolute pathname of the currently executing script
$_SERVER['SERVER_ADMIN'] Returns the value given to the SERVER_ADMIN directive in the web server configuration file (if your script runs on a virtual host, it will be the value defined for that virtual host) (such as someone@w3schools.com)
$_SERVER['SERVER_PORT'] Returns the port on the server machine being used by the web server for communication (such as 80)
$_SERVER['SERVER_SIGNATURE'] Returns the server version and virtual host name which are added to server-generated pages
$_SERVER['PATH_TRANSLATED'] Returns the file system based path to the current script
$_SERVER['SCRIPT_NAME'] Returns the path of the current script
$_SERVER['SCRIPT_URI'] Returns the URI of the current page

No comments:

Post a Comment