Sie sind auf Seite 1von 5

How can we know the count/number of elements of an array?

2 ways:
a) sizeof($array) - This function is an alias of count()
b) count($urarray) - This function returns the number of
elements in an array. Interestingly if you just pass a
simple var instead of an array, count() will return 1.

How can we find the number of rows in a result set using PHP?
Answer1
Here is how can you find the number of rows in a result set
in PHP: $result = mysql_query($any_valid_sql,
$database_link); $num_rows = mysql_num_rows($result); echo
“$num_rows rows found”;
Answer2
<?php //first establish connection with database
mysql_connect("localhost","root","");
mysql_select_db("demoprj");
// then write the query suppose our table is tbl_student
$sql_stu="select* from tbl_student";
$res_stu=mysql_query($sql_stu);
$rows_stu=mysql_num_rows($res_stu);
echo"number of rows in tbl_student are=".$rows_stu;
?>

which function used to get the file name in php?


Answer1
<?php
$path = "/home/httpd/html/index.php";
$file = basename($path);
$file = basename($path, ".php");
?>
Answer 2
The file name on the browser system
$file_name=$_FILES[$fieldName]['name'];
Answer 3
$parts = Explode('/', $_SERVER["SCRIPT_NAME"]);
$currentFile = $parts[count($parts) - 1];

explain in brief type juggling in php?


Answer
PHP does not require (or support) explicit type definition
in variable declaration; a variable's type is determined by
the context in which that variable is used. That is to say,
if you assign a string value to variable $var, $var becomes
a string. If you then assign an integer value to $var, it
becomes an integer.

An example of PHP's automatic type conversion is the


addition operator '+'. If any of the operands is a float,
then all operands are evaluated as floats, and the result
will be a float. Otherwise, the operands will be interpreted
as integers, and the result will also be an integer. Note
that this does NOT change the types of the operands
themselves; the only change is in how the operands are
evaluated.
$foo += 2; // $foo is now an integer (2)
$foo = $foo + 1.3; // $foo is now a float (3.3)
$foo = 5 + "10 Little Piggies"; // $foo is integer (15)
$foo = 5 + "10 Small Pigs"; // $foo is integer (15)

If the last two examples above seem odd, see String


conversion to numbers.
If you wish to change the type of a variable, see settype().
If you would like to test any of the examples in this
section, you can use the var_dump() function.
Note: The behavior of an automatic conversion to array is
currently undefined.

Since PHP (for historical reasons) supports indexing into


strings via offsets using the same syntax as array indexing,
the example above leads to a problem: should $a become an
array with its first element being "f", or should "f" become
the first character of the string $a? The current versions
of PHP interpret the second assignment as a string offset
identification, so $a becomes "f", the result of this
automatic conversion however should be considered undefined.
PHP 4 introduced the new curly bracket syntax to access
characters in string, use this syntax instead of the one
presented above

difference of move(), and copy() function in php?


Answer 1
copy() function copy images for temp folder on server to
move other location. move() function cut images for temp
folder on server to move other location.
Answer 2
copy() = copy and move() = cut in simple terms.

Describe arguments in header in php?


Answer
header() function has three arguments

1)string:Required. Specifies the header string to send


2)replace: Optional. Indicates whether the header should
replace previous or add a second header. Default is TRUE
(will replace). FALSE (allows multiple headers of the same type)
3)http_response_code:Optional. Forces the HTTP response code
to the specified value

how many error types in php? name there?


Answer 1
four type of error in php. 1.fatal 2.notice 3.warning
4.parse
Answer2
four type of error in php. 1.fatal 2.notice 3.warning
4.parse
Answer 3
four type of error in php. 1.fatal 2.notice 3.warning
4.parse
Answer 4
four type of error in php. 1.fatal 2.notice 3.warning
4.parse, for fatal and warning errors excutions will be stop.

where to change in php.ini file for file uploading?


Answer
You can call the phpinfo() function to find the location of
your php.ini file, it will also tell you the current values
for the following settings that we need to modify

1.file_uploads
2.upload_max_filesize
3.max_input_time
4.memory_limit
5.max_execution_time
6.post_max_size

how long a default session stay in php?


Answer
Default session time is 24 minutes in php
Answer
It is 24 Hour in PHP.
Answer
by default the life of a session is 20 minutes.
Answer
24 minuts is the default time in php
Answer
It is 24 Hour in PHP.
Answer
We can define it in php.ini
that how much time you want...
Answer
By default it is 180 minutes. check session.cache_expire
value in phpinfo().
Answer
By default it is 24 minutes

what is pear in php in brief ?


Answer
PEAR is short for "PHP Extension and Application
Repository". PEAR is the next revolution in PHP. This
repository is bringing higher level programming to PHP. PEAR
is a framework and distribution system for reusable PHP
components. It eases installation by bringing an automated
wizard, and packing the strength and experience of PHP users
into a nicely organised OOP library. PEAR also provides a
command-line interface that can be used to automatically
install "packages"

Which function used to get the number of days between two


given dates in php
Answer
<?php
$days = (strtotime("2005-11-26") - strtotime("2005-11-20"))
/ (60 * 60 * 24);
print $days;
?>
This code print number of days between two dates

how many types of inheritance is there in php? name there?


Answer
There are three types of inheritance in php1.single,2.multiple,3.multi level
Answer
php supports single,multilevel,hierarchy
Answer
php supports single and multilevel inheritance basically
multiple inheritance supported by c++ only.

What IS PHP?
Answer
PHP: Hypertext Preprocessor, an open source, server-side,
HTML embedded scripting language used to create dynamic Web
pages. In an HTML document, PHP script (similar syntax to
that of Perl or C ) is enclosed within special PHP tags.
Because PHP is embedded within tags,And, because PHP is
executed on the server, the client cannot view the PHP code.
PHP can perform any task!
Answer
PHP:Preprocessor Hypertext or Personal Home Page open
source,server side script language used to create
software,sites.We can combine the PHP code with HTML with
the help of tags <? ?>.

what is mean php ? is it designingtool or language?


how ill create website using by php?
Answer
PHP is stands for PHP hypertext preprocessor.It is an
server site scripting language.

why header() gives the error like header already sent in php
please explain in brief
Answer
Generally it gives error when u print or echo some content
before header() or setcookie() methods.

To avoid the error just put the print below header();


POST and GET Methods Which will execute faster POST or GET? Explain

Das könnte Ihnen auch gefallen