Found 1466 Articles for PHP

chgrp()function in PHP

Samual Sam
Updated on 24-Jun-2020 08:37:16

182 Views

The chgroup() function updates the file group. Remember that only the superuser has the authority to change the group of a file arbitrarily,Syntaxchgroup($file_path, group)Parametersfile_path − Set the path of file or directory to be checked. Required.group − Set the new user group name or number.ReturnThe chgroup() function returns.True, on success,False, on failureExampleThe following is an example that checks for file “one.txt” and changes its file group.OutputTRUE TRUE

basename( ) function in PHP

karthikeya Boyini
Updated on 24-Jun-2020 08:37:40

302 Views

The basename() function gets the the filename component of a path. The file path is set as a parameter.Syntaxbasename(file_path, suffix)Parametersfile_path − Set the path of file or directory to be checked. Required.suffix − Set the extension of the file. Optional.ReturnThe basename() function returns the basename of the file.ExampleThe following is an example that checks for file “new.php” and returns the basename with the extension since we added the suffix parameter. Live DemoOutputnew.phpExampleLet us see another example that checks the file and display the basename without the extension. Live DemoOutputnew

file_exists() function in PHP

Samual Sam
Updated on 24-Jun-2020 08:38:04

450 Views

The file_exists method check whether a file or directory exists or not. It accepts the path of the file or directory to be checked as the parameter. The following are its uses −It is useful when you need to know whether a file exists or not before processing.With that, use this function while creating a new file to know whether the file already exists or not.Syntaxfile_exists($file_path)Parametersfile_path − Set the path of file or directory to be checked for existence.Required.ReturnThe file_exists() method returns.True, if the file or directory existsFalse, if the file or directory does not existExampleLet us see an example ... Read More

Using HTML5 Server-Sent Events in a web application

Jennifer Nicholas
Updated on 20-Dec-2019 10:49:19

151 Views

To use Server-Sent Events in a web application, you would need to add an element to the document.The src attribute of the element should point to an URL that should provide a persistent HTTP connection that sends a data stream containing the events.The URL would point to a PHP, PERL or any Python script that would take care of sending event data consistently.ExampleHere is an example showing application that would expect server time.                    /* Define event handling logic here */                                                              

PHP timestamp to HTML5 input type=datetime element

karthikeya Boyini
Updated on 20-Dec-2019 10:47:47

644 Views

For HTML5 input time, in PHP:Exampleecho date("Y-m-d\TH:i:s");OutputThe output would be:2018-28-03T19:12:49HTML with Timestamp would be:

How can we write PHP script to get the list of MySQL database?

Priya Pallavi
Updated on 22-Jun-2020 14:31:14

934 Views

We can write the following PHP script to get the list of available MySQL databases −Example

How can we write PHP script to count the affected rows by MySQL query?

vanithasree
Updated on 22-Jun-2020 14:30:45

256 Views

PHP uses mysql_affected_rows( ) function to find out how many rows a query changed. To illustrate it we are having the following example −Example           Rows affected by query                  

Which PHP function is used to give the number of rows affected by MySQL query?

Nikitha N
Updated on 22-Jun-2020 14:08:04

154 Views

PHP uses mysql_affected_rows( ) function to find out how many rows a query changed. This function basically returns the number of affected rows in the previous SELECT, INSERT, UPDATE, REPLACE, or DELETE query. Return of an integer > 0 indicates the number of rows affected, 0 indicates that no records were affected and -1 indicates that the query returned an error. Its syntax is as follows −Syntaxmysql_affected_rows( connection );Followings are the parameters used in this function −S. No.Parameter & Description1.ConnectionRequired – Specifies the MySQL connection to use

How can we create a MySQL temporary table by using PHP script?

radhakrishna
Updated on 22-Jun-2020 14:08:57

1K+ Views

As we know that PHP provides us the function named mysql_query() to create a MySQL table. Similarly, we can use mysql_query() function to create MySQL temporary table. To illustrate this, we are using the following example −ExampleIn this example, we are creating a temporary table named ‘SalesSummary’ with the help of PHP script in the following example −           Creating MySQL Temporary Tables              

How can we handle NULL values stored in a MySQL table by using PHP script?

Srinivas Gorla
Updated on 22-Jun-2020 14:09:52

270 Views

We can use the if...else condition in PHP script to prepare a query based on the NULL value. To illustrate it we are having the following example −ExampleIn this example, we are using the table named ‘tcount_tbl’ having the following data −mysql> SELECT * from tcount_tbl; +-----------------+----------------+ | tutorial_author | tutorial_count | +-----------------+----------------+ |      mahran     |       20       | |      mahnaz     |      NULL      | |       Jen       |      NULL      | |      Gill       |       20       | +-----------------+----------------+ 4 rows in set (0.00 sec)Now, the following is a PHP script that takes the value of ‘tutorial_count’ from outside and compares it with the value available in the field.

Advertisements