PHP Pass variable to next page

后端 未结 8 2338
Happy的楠姐
Happy的楠姐 2020-11-21 06:40

It seems pretty simple but I can\'t find a good way to do it.

Say in the first page I create a variable

$myVariable = \"Some text\";
<
8条回答
  •  南笙
    南笙 (楼主)
    2020-11-21 06:52

    There are three method to pass value in php.

    • By post
    • By get
    • By making session variable

    These three method are used for different purpose.For example if we want to receive our value on next page then we can use 'post' ($_POST) method as:-

    $a=$_POST['field-name'];
    

    If we require the value of variable on more than one page than we can use session variable as:-

    $a=$_SESSION['field-name];
    

    Before using this Syntax for creating SESSION variable we first have to add this tag at the very beginning of our php page

    session_start(); 
    

    GET method are generally used to print data on same page which used to take input from user. Its syntax is as:

    $a=$_GET['field-name'];
    

    POST method are generally consume more secure than GET because when we use Get method than it can display the data in URL bar.If the data is more sensitive data like password then it can be inggeris.

提交回复
热议问题