answersLogoWhite

0

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>

User Avatar

Wiki User

13y ago

What else can I help you with?

Continue Learning about Basic Math

You use a Html button in Php on its onclick you made a function but its not responding?

this is not really a question... But I think you are asking why php functions inside a HTML button do not work. Well probably because php is rendered serverside and is passed to a user-browser afterwards.... it is possible to use php inside onclick... but only to display specific content (javascript function for instance)... it is not possible to let a user decide to run a specific php function by clicking a button.


How do you create static variables in PHP?

Use the "static" keyword to declare a static variable within a function like shown below. &lt;?php function fun() { static $variable; static $another_variable = ''; } ?&gt;


What lines of code make up a function in php?

A user defined function in PHP is set up of several key components.First, the function keyword; this lets PHP know that you're setting up a function. Then the function name, which lets you later use your function. After that, the parametersthe function requires to operate. Finally, just the bracketssurrounding your function, setting it apart from the rest of your code.function nameHere ($parameterOne, $parameterTwo) {functionCodeHere();}


How do you return a value in a PHP function?

Below is a simple example of how you could return a value in a PHP function. &lt;?php function returnme($value) { return $value; } echo returnme('hello'); // outputs: hello ?&gt;


How do you check the length of a string in PHP?

It is fairly simple to check the length of a string in PHP. All you need to do is use the function strlen(). Below is an example of how it is used. &lt;?php $my_text = "Hello"; echo strlen($my_text); // outputs 5 ?&gt;

Related Questions

You use a Html button in Php on its onclick you made a function but its not responding?

this is not really a question... But I think you are asking why php functions inside a HTML button do not work. Well probably because php is rendered serverside and is passed to a user-browser afterwards.... it is possible to use php inside onclick... but only to display specific content (javascript function for instance)... it is not possible to let a user decide to run a specific php function by clicking a button.


How do you use settime out in php?

we cant use set timeout function in php because it is of java script function


How do you create a web mail script using PHP?

You can use phpMailer() Or, you can use mail() PHP function to send emails via PHP script.


How can files be converted into HTML using PHP?

To rename a file in PHP the easiest way to do it is to use the rename() function. &lt;?php rename("before.txt", "after.html"); ?&gt;


How do you include a file in PHP?

To include a file in PHP all you need to do is use the include() function as I have shown you in the example below. &lt;?php include("filename.php"); ?&gt;


How can you connect php to msql?

Use mysql_connect() php function to connect to the mysql.Please refer related link for more details.


What is a PHP function?

Functions are basic blocks of code that work together. Functions can be used from the core PHP or can be created by users. To create a function, use the following syntax: function function_name(arg1, arg2, ... argX) { //Any valid php code here } To use a function, use the following syntax: function_name(arg1, arg2, ... argX);


Can you use Perl regular expressions in PHP?

Yes, by using the preg_match() function


How do you create static variables in PHP?

Use the "static" keyword to declare a static variable within a function like shown below. &lt;?php function fun() { static $variable; static $another_variable = ''; } ?&gt;


What lines of code make up a function in php?

A user defined function in PHP is set up of several key components.First, the function keyword; this lets PHP know that you're setting up a function. Then the function name, which lets you later use your function. After that, the parametersthe function requires to operate. Finally, just the bracketssurrounding your function, setting it apart from the rest of your code.function nameHere ($parameterOne, $parameterTwo) {functionCodeHere();}


How do you separate word in array using php?

To separate a sentence into an array of words, you can use PHP's explode() function. If $text is your sentence, then use the following: $result = explode(" ", $text);


How crearte a function in php?

The simplest way (the old procedural way) is to just declare the function: function ourSimpleFunction(){ //Function Guts } Functions do not require a return type, or typed arguments in PHP, however you can use type-hinting if it makes you feel better.