In PHP, the exit() function calls and end to the script in much the same way as when the end of the script is reached naturally. Objects are destructed, garbage cleaned, and everything is wrapped up nicely and neatly. This is as opposed to die(), which just stops the script where it is without allowing other final processes to complete.
Please see this example as below. <?php $first_variable = "Heloooo"; function first_method(){ print 'Heloooo'; } class firstClass{ public $testvar=""; function firstClass(){ // initialize $this->testvar = "Hiiiiiii"; } function first_method_inclass(){ print 'Heloooo'; } } ?>
A PHP file is a text file containing code to be run on a webserver by a program called php. It's the most used dynamic page script engine as it is free and open source.Use the fopen() function to open files in PHP. The first parameter of this function is the file to be opened and the second parameter specifies in which mode the file should be opened
PHP has built-in one way hashing using the md5 function. Additional encryption capabilities are available using the Mcrypt extension.
PHP code can be stored in any kind of file -- the extension of the file indicates what said file contains, but may not necessarily be true. The "php" extension is used to indicate PHP which is meant for execution and presentation.
Classes are not like predefined functions-there are quite a lot of functions, a class is similar to creating your own function - on a very basic level please do not swamp me with lists of the differences between a class and a function I already know! - anyway, anything predefined within php will be available to view in the PHP manual - downloadable from the php website and is part of the php package. but to save you a bit of time here are a list of pre-defined classes (or rather resevered words that are classes): http://php.net/manual/en/reserved.classes.php
in php used for one typ website
header() is a php function used to modify and set HTTP headers sent to the browser.
It gets options from the command line argument list. It can be used in PHP 4.3 and above, including PHP 5.
Here is the code below to redirect a webpage using php: <?php header('Location: url of the webpage'); // example: header('Location: index.php') exit; // exit after redirection is very important as php executes code line by line ?>
The function die() stops the script from running. See the example below: <?php die("this text will be outputted on the page"); echo "this text will not be shown due to the script ending when the die() function was called"; ?>
we cant use set timeout function in php because it is of java script function
Below is a simple example of how you could return a value in a PHP function. <?php function returnme($value) { return $value; } echo returnme('hello'); // outputs: hello ?>
function function_name() { .................... }
Flags in PHP are just a kind of constants. They map to a number and are used as optional function parameters. For instance in a file_put_contents() function there is a flag called FILE_APPEND, which appends the data to the file instead of overwriting it.
Please see this example as below. <?php $first_variable = "Heloooo"; function first_method(){ print 'Heloooo'; } class firstClass{ public $testvar=""; function firstClass(){ // initialize $this->testvar = "Hiiiiiii"; } function first_method_inclass(){ print 'Heloooo'; } } ?>
The eval() function evaluates a string as PHP code. http://us.php.net/manual/en/function.eval.php
A simple function call <html> <body> <?php if(isset($_POST['button'])) { setValue(); // Function is called } function setValue() { echo "<br>The button property to call PHP function works"; // Your code here } ?> <input type="submit" name="button" onclick=<?php $_SERVER['PHP_SELF']; ?> /> </body> </head>