Showing posts with label scripting. Show all posts
Showing posts with label scripting. Show all posts

php functions explained -- func_num_args() and func_get_args()

1. func_num_args()
2. func_get_args()

These are two php functions used to find number of arguments passed to a function and get get argument values.

For more details visit php manual

why this functions?

These functions are used in function oveloading to find number of arguments passed and there values. .
Usual method of function overloading not works in php.

Pass variables from one page to another

Here is a simple method to Pass variables from one page to another

Here is the code in first page

<a href="page2.php?nam=sree">click here</a>


In your second page you can access variable name as


$name=$_GET['nam'];
echo $name;

This code will display sree

php error -(Parse error: syntax error, unexpected T_DNUMBER, expecting ',' or ';')

Parse error: syntax error, unexpected T_DNUMBER, expecting ',' or ';'

This error occur when a number comes when expecting a string .
For example the following code produces error because a string is concatenated with integer.


<?php
echo "example".1;
?>

php errors- (Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';')

2. Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';'

This error occurs when a semicolon missing

For example following code produces this error because of missing a semicolon in second line


<php
echo $s
?>

php errors- Parse error: syntax error, unexpected T_ECHO

Errors are very helpful to programmers .When you identifies cause of error next time that error will not be a challenge for you.
Here i am providing some common errors

1.Parse error: syntax error, unexpected T_ECHO

This error is due to some unidentified symbol or character in code

For example following code produces the above error because of "character x" in code

<?php
x
echo "error example";
?>