Latest questions in PHP

0 votes
1 answer

How to trigger XDebug profiler for a command line PHP script?

Hello @kartik, You can pass INI settings with ...READ MORE

Sep 17, 2020 in PHP by Niroj
• 82,880 points
1,427 views
0 votes
1 answer

How to get the location from an IP address?

Hello @kartik, You could download a free GeoIP ...READ MORE

Sep 17, 2020 in PHP by Niroj
• 82,880 points
2,120 views
+1 vote
2 answers

How to make asynchronous HTTP requests in PHP?

Hello @kartik, Use this code: function post_without_wait($url, $params) { ...READ MORE

Sep 17, 2020 in PHP by Niroj
• 82,880 points
2,353 views
0 votes
1 answer

How to display HTML tags as plain text ?

Hello @kartik, Replace < with &lt; and& ...READ MORE

Sep 17, 2020 in PHP by Niroj
• 82,880 points
2,506 views
0 votes
1 answer

How to remove all special characters from a string?

Hello @kartik, This should do what you're looking ...READ MORE

Sep 17, 2020 in PHP by Niroj
• 82,880 points
10,702 views
0 votes
1 answer

Error:PHP Warning: POST Content-Length of 8978294 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

Hello @kartik, 8388608 bytes is 8M, the default ...READ MORE

Sep 17, 2020 in PHP by Niroj
• 82,880 points
27,626 views
0 votes
1 answer

How to secure database passwords in PHP

Hello @kartik, If you're hosting on someone else's ...READ MORE

Sep 16, 2020 in PHP by Niroj
• 82,880 points
567 views
0 votes
1 answer

How can I get useful error messages in PHP?

Hello @kartik, The following enables all errors: ini_set('display_startup_errors', 1); ini_set('display_errors', ...READ MORE

Sep 16, 2020 in PHP by Niroj
• 82,880 points
341 views
0 votes
1 answer

How can I capture the result of var_dump to a string?

Hello @kartik, Try var_export You may want to check out var_export — ...READ MORE

Sep 16, 2020 in PHP by Niroj
• 82,880 points
950 views
0 votes
1 answer

How do I send a POST request with PHP?

Hello @kartik, CURL-less method with PHP5: $url = 'http://server.com/path'; $data ...READ MORE

Sep 16, 2020 in PHP by Niroj
• 82,880 points
2,724 views
0 votes
1 answer

How do I get a file extension in PHP?

Hello @kartik, pathinfo() $path_info = pathinfo('/foo/bar/baz.bill'); echo $path_info['extension']; // "bill" Hope ...READ MORE

Sep 16, 2020 in PHP by Niroj
• 82,880 points
787 views
0 votes
1 answer

Error:Cannot modify header information - headers already sent by (output started at /some/file.php:12) in /some/file.php on line 23

Hello @kartik, This error message gets triggered when anything is ...READ MORE

Sep 16, 2020 in PHP by Niroj
• 82,880 points
5,406 views
0 votes
1 answer

How to delete element by value in array (not key) using php?

Hello @kartik, Using array_search() and unset, try the following: if (($key = ...READ MORE

Sep 16, 2020 in PHP by Niroj
• 82,880 points
1,627 views
0 votes
1 answer

Error:mysql_fetch_array() expects parameter 1 to be resource, boolean given

Hello @kartik, Error occurred here was due to ...READ MORE

Sep 16, 2020 in PHP by Niroj
• 82,880 points
3,514 views
0 votes
1 answer

How to Get the full URL in PHP?

Hello @kartik, Have a look at $_SERVER['REQUEST_URI'], i.e. $actual_link = ...READ MORE

Sep 16, 2020 in PHP by Niroj
• 82,880 points
2,927 views
0 votes
1 answer

How do I make a redirect in PHP?

Hello @kartik, Use the header() function to send an HTTP Location header: header('Location: '.$newURL); Contrary to ...READ MORE

Sep 16, 2020 in PHP by Niroj
• 82,880 points
516 views
0 votes
1 answer

How to generate .json file with PHP?

Hello @kartik, Here is a sample code: <?php $sql="select ...READ MORE

Sep 15, 2020 in PHP by Niroj
• 82,880 points
2,550 views
0 votes
1 answer

How can I convert the output of PHP's filesize() function to a format with MegaBytes, KiloBytes etc?

Hello @kartik, Here is a sample: <?php // Snippet from ...READ MORE

Sep 15, 2020 in PHP by Niroj
• 82,880 points
3,404 views
0 votes
1 answer

How to delete object from array inside foreach loop?

Hello @kartik, Use this: foreach($array as $elementKey => $element) ...READ MORE

Sep 15, 2020 in PHP by Niroj
• 82,880 points
6,619 views
0 votes
1 answer

How do I get the base URL with PHP?

Hello @kartik, Try this: <?php echo "http://" . $_SERVER['SERVER_NAME'] ...READ MORE

Sep 15, 2020 in PHP by Niroj
• 82,880 points
20,349 views
0 votes
1 answer

How to remove duplicate values from an array in PHP?

Hello @kartik, Use array_unique(): Example: $array = array(1, 2, 2, 3); $array ...READ MORE

Sep 15, 2020 in PHP by Niroj
• 82,880 points
2,535 views
0 votes
1 answer

How to change the session timeout in PHP?

Hello @kartik, Put $_SESSION['login_time'] = time(); into the previous authentication ...READ MORE

Sep 15, 2020 in PHP by Niroj
• 82,880 points
4,018 views
0 votes
1 answer

How can I select and upload multiple files with HTML and PHP using HTTP POST?

Hello @kartik, This is possible in HTML5. Example (PHP ...READ MORE

Sep 15, 2020 in PHP by Niroj
• 82,880 points
1,661 views
0 votes
1 answer

How do I see the extensions loaded by PHP?

Hello @kartik, Running php -m will give you all the ...READ MORE

Sep 15, 2020 in PHP by Niroj
• 82,880 points
307 views
0 votes
1 answer

How to copy a file from one directory to another using PHP?

Hello @kartik, You could use the copy() function : // Will ...READ MORE

Sep 15, 2020 in PHP by Niroj
• 82,880 points
1,128 views
0 votes
1 answer

How to Get $_POST from multiple checkboxes?

Hello @kartik, Set the name in the form ...READ MORE

Sep 15, 2020 in PHP by Niroj
• 82,880 points
3,241 views
0 votes
1 answer

How to Convert timestamp to readable date/time PHP?

Hello @kartik, Use PHP's date() function. Example: echo date('m/d/Y', 1299446702); Hope it helps!! Thank ...READ MORE

Sep 14, 2020 in PHP by Niroj
• 82,880 points
1,873 views
0 votes
1 answer

How to send HTTP response code?

Hello @kartik, you can use http_response_code() for get and set ...READ MORE

Sep 14, 2020 in PHP by Niroj
• 82,880 points
691 views
0 votes
1 answer

How to receive JSON POST with PHP?

Hello @kartik, Try; $data = json_decode(file_get_contents('php://input'), true); print_r($data); echo $data["operacion"]; From your ...READ MORE

Sep 14, 2020 in PHP by Niroj
• 82,880 points
13,836 views
0 votes
1 answer

How do you Encrypt and Decrypt a PHP String?

Hello @kartik, Use openssl_encrypt and openssl_decrypt You can do something like: $string_to_encrypt="Test"; $password="password"; $encrypted_string=openssl_encrypt($string_to_encrypt,"AES-128-ECB",$password); $decrypted_string=openssl_decrypt($encrypted_string,"AES-128-ECB",$password); Hope it ...READ MORE

Sep 14, 2020 in PHP by Niroj
• 82,880 points
8,017 views
0 votes
1 answer

How do I log errors and warnings into a file?

Hello @kartik, Use the following code: ini_set("log_errors", 1); ini_set("error_log", "/tmp/php-error.log"); error_log( ...READ MORE

Sep 14, 2020 in PHP by Niroj
• 82,880 points
353 views
0 votes
1 answer

How to configure XAMPP to send mail from localhost?

Hello @kartik, You can send mail from localhost ...READ MORE

Sep 14, 2020 in PHP by Niroj
• 82,880 points
11,501 views
0 votes
1 answer

Error:PDOException could not find driver

Hello @kartik, You need to have a module ...READ MORE

Sep 14, 2020 in PHP by Niroj
• 82,880 points
13,655 views
0 votes
1 answer

How do I use the json_encode() function with MySQL query results?

Hello @kartik, Use this: $sth = mysqli_query($conn, "SELECT ..."); $rows ...READ MORE

Sep 14, 2020 in PHP by Niroj
• 82,880 points
3,373 views
0 votes
1 answer

How I can make a query with MySQL that checks if the valuein a certain column contains certain data?

Hello @kartik, Try this query: mysql_query(" SELECT * FROM `table` WHERE `column` ...READ MORE

Sep 14, 2020 in PHP by Niroj
• 82,880 points
2,849 views
0 votes
1 answer

How to delete all files from a folder using PHP?

Hello @kartik, Use this: $files = glob('path/to/temp/*'); // get ...READ MORE

Sep 14, 2020 in PHP by Niroj
• 82,880 points
1,147 views
0 votes
1 answer

Notice: Undefined index: bid in C:\xampp\htdocs\userac\courier_management_system-master\courier_management_system-master\addstaff.php on line 130

Hello @saima , Before you extract values from $_POST ,$_SESSION, ...READ MORE

Sep 14, 2020 in PHP by Niroj
• 82,880 points
2,615 views
0 votes
1 answer

How to increase the execution timeout in php?

Hello @kartik, You need to change some setting ...READ MORE

Sep 1, 2020 in PHP by Niroj
• 82,880 points
1,000 views
0 votes
1 answer

How to get file_get_contents() to work with HTTPS?

Hello @kartik, Try the following script to see ...READ MORE

Sep 1, 2020 in PHP by Niroj
• 82,880 points
4,493 views
0 votes
1 answer

Error: Maximum execution time of 60 seconds exceeded in C:\xampp\phpmyadmin\libraries\dbi\mysql.dbi.lib.php on line 140

Hello @kartik, Go to: xampp\phpMyAdmin\libraries\config.default.php Look for : $cfg['ExecTimeLimit'] = 600; You ...READ MORE

Sep 1, 2020 in PHP by Niroj
• 82,880 points
13,931 views
0 votes
1 answer

How to get original URL referer with PHP?

Hello @kartik, Store it either in a cookie or ...READ MORE

Sep 1, 2020 in PHP by Niroj
• 82,880 points
17,087 views
0 votes
1 answer

Error:Internal server errordisplay in PHP via htaccess only

Hello @kartik,  Try adding this line .htaccess: php_flag display_startup_errors ...READ MORE

Sep 1, 2020 in PHP by Niroj
• 82,880 points
655 views
0 votes
1 answer

Error:Got a packet bigger than 'max_allowed_packet'bytes

Hello @kartik, max_allowed_packet is set in mysql config, not ...READ MORE

Sep 1, 2020 in PHP by Niroj
• 82,880 points
4,709 views
0 votes
1 answer

How to get current URL path in PHP?

Hello @kartik, Use $_SERVER['REQUEST_URI'].  The URI which was given in ...READ MORE

Sep 1, 2020 in PHP by Niroj
• 82,880 points
3,732 views
0 votes
1 answer

How to get Root Directory Path of a PHP project?

Hello @kartik, Try $_SERVER['DOCUMENT_ROOT'] contains this path: D:/workspace In that case you ...READ MORE

Sep 1, 2020 in PHP by Niroj
• 82,880 points
22,356 views
0 votes
1 answer

How to store values from foreach loop into an array?

Hello @kartik, Declare the $items array outside the loop and ...READ MORE

Sep 1, 2020 in PHP by Niroj
• 82,880 points
28,880 views
0 votes
1 answer

How to pass arrays as url parameter?

Hello @kartik, There is a very simple solution: http_build_query(). ...READ MORE

Sep 1, 2020 in PHP by Niroj
• 82,880 points
5,929 views
0 votes
1 answer

How do I check whether a checkbox is checked in jQuery?

Hello @kartik, The checked property of a checkbox DOM element ...READ MORE

Aug 28, 2020 in PHP by Niroj
• 82,880 points
604 views
0 votes
1 answer

How can I remove a specific item from an array?

Hello @kartik, Find the index of the array element you ...READ MORE

Aug 28, 2020 in PHP by Niroj
• 82,880 points
466 views
0 votes
1 answer

How to get current PHP page name?

Hello @kartik, You can use basename() and $_SERVER['PHP_SELF'] to get current page ...READ MORE

Aug 28, 2020 in PHP by Niroj
• 82,880 points
2,690 views