Trending questions in PHP

0 votes
1 answer

How to remove GET-variables with PHP?

Hello @kartik, Try this: preg_replace('/\\?.*/', '', $str) Hope ...READ MORE

Oct 27, 2020 in PHP by Niroj
• 82,880 points
1,839 views
0 votes
1 answer

How do I save value in my own session variable in Magento?

Hello @kartik, Try this: $session = Mage::getSingleton("core/session", array("name"=>"frontend")); // ...READ MORE

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

How to prevent direct access to a php include file?

Hello @kartik, Add this to the page that ...READ MORE

Oct 1, 2020 in PHP by Niroj
• 82,880 points
2,939 views
0 votes
1 answer

How to properly indent PHP/HTML mixed code?

Hello @kartik, The PHP and the HTML should ...READ MORE

Oct 30, 2020 in PHP by Niroj
• 82,880 points
1,684 views
0 votes
1 answer

How to GET URL parameter in PHP?

Hello @kartik, $_GET is not a function or language ...READ MORE

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

How do I get the last inserted ID of a MySQL table in PHP?

Hello @kartik, If you're using PDO, use PDO::lastInsertId. If you're ...READ MORE

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

How can I handle the warning of file_get_contents() function in PHP?

Hello @kartik, This is fairly simple: if (!$data = ...READ MORE

Apr 7, 2020 in PHP by Niroj
• 82,880 points
10,492 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,485 views
0 votes
1 answer

How do I escape a single quote in SQL Server?

Hello @kartik, Single quotes are escaped by doubling ...READ MORE

Jul 21, 2020 in PHP by Niroj
• 82,880 points
5,881 views
0 votes
1 answer

How to set max_execution_time in PHP CLI?

Hello, set_time_limit() works in CLI scripts. <?php set_time_limit(1); //in ...READ MORE

Nov 14, 2020 in PHP by Niroj
• 82,880 points
862 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,382 views
0 votes
1 answer

How can one check to see if a remote file exists using PHP?

Hello @kartik, You can instruct curl to use ...READ MORE

Nov 10, 2020 in PHP by Niroj
• 82,880 points
957 views
0 votes
1 answer

How to Check for a Specific Type of Object in PHP

Hello @kartik, You can use instanceof: if ($pdo instanceof PDO) ...READ MORE

Oct 30, 2020 in PHP by Niroj
• 82,880 points
1,444 views
0 votes
1 answer

How to grant remote access permissions to mysql server for user?

Hello @kartik, This grants root access with the ...READ MORE

Aug 26, 2020 in PHP by Niroj
• 82,880 points
4,221 views
0 votes
1 answer

How can to make a query with LIKE and get all results with mysqli ?

Hello @kartik, Here's how you properly fetch the ...READ MORE

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

How to get name of current directory using php?

Hello @kartik, To get only the name of ...READ MORE

Aug 27, 2020 in PHP by Niroj
• 82,880 points
4,169 views
0 votes
1 answer

How can I disable XDebug using php?

Hello @kartik, Find your php.ini and look for XDebug. Set xdebug ...READ MORE

Aug 27, 2020 in PHP by Niroj
• 82,880 points
4,142 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,359 views
0 votes
1 answer

Error: Premature end of script headers: backup.php

Hello @kartik< Try this settings on my apache.conf: <VirtualHost ...READ MORE

Nov 14, 2020 in PHP by Niroj
• 82,880 points
658 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,213 views
0 votes
1 answer

How do I access static member of a class?

Hello, If A is a class, you can access it ...READ MORE

Nov 20, 2020 in PHP by Niroj
• 82,880 points
334 views
0 votes
1 answer

How to read a list of files from a folder using PHP?

Try this: $files = array_values(array_filter(scandir($path), function($file) use ($path) ...READ MORE

Nov 18, 2020 in PHP by Niroj
• 82,880 points
425 views
0 votes
1 answer

How to know which php.ini is used?

Hello @kartik, ou can use php_ini_loaded_file() Taken from php.net: $inipath = ...READ MORE

Oct 30, 2020 in PHP by Niroj
• 82,880 points
1,218 views
0 votes
1 answer

How to embed PHP code in JavaScript?

Hello, If your whole JavaScript code gets processed ...READ MORE

Nov 9, 2020 in PHP by anonymous
• 82,880 points
754 views
0 votes
1 answer

How to discard a variable from a PHP session array

Hello, Try this: if (isset($_POST['remove'])) { ...READ MORE

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

How to access array returned by a function in php?

Hello @kartik, Since PHP 5.4 it's possible to ...READ MORE

Nov 10, 2020 in PHP by anonymous
• 82,880 points
682 views
0 votes
1 answer

How do I save value in my own session variable in Magento?

Hello @kartik, Let's say you want to save ...READ MORE

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

How do I specify unique constraint for multiple columns in MySQL?

Hello @kartik, Use this: ALTER TABLE `votes` ADD UNIQUE ...READ MORE

Aug 18, 2020 in PHP by Niroj
• 82,880 points
4,307 views
0 votes
1 answer

How to Automatically Start a Download in PHP?

Hello @kartik, Send the following headers before outputting ...READ MORE

Nov 5, 2020 in PHP by Niroj
• 82,880 points
887 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,713 views
0 votes
1 answer

How do I make an asynchronous GET request in PHP?

Hello @kartik, Works with both POST and GET ...READ MORE

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

How to exclude certains columns while using eloquent using php?

Hello @kartik, using hidden array in model is good, but ...READ MORE

Nov 6, 2020 in PHP by Niroj
• 82,880 points
811 views
0 votes
1 answer

How do I embed PHP code in JavaScript?

Hello @kartik, If your whole JavaScript code gets ...READ MORE

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

How can I get PHP to produce a backtrace upon errors?

Hello @kartik, My script for installing an error ...READ MORE

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

How can I get PHP to produce a backtrace upon errors?

Hello @kartik, This is how you do it: set_error_handler(function($errorType){ ...READ MORE

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

Fatal error: Cannot access empty property in C:\xampp\htdocs\MyTestPages\f.php on line 15

Hello @kartik, You access the property in the ...READ MORE

Oct 19, 2020 in PHP by Niroj
• 82,880 points
1,525 views
0 votes
1 answer

How to prevent direct access to a php include file?

Hello @kartik, Add this to the page that ...READ MORE

Oct 19, 2020 in PHP by Niroj
• 82,880 points
1,505 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,888 views
0 votes
1 answer

How do I capture PHP output into a variable?

Hello, Try this: <?php ob_start(); ?> <xml/> <?php $xml = ob_get_clean(); ...READ MORE

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

How do I convert a PDF document to a preview image in PHP?

Hello @kartik, You need ImageMagick and GhostScript <?php $im = new imagick('file.pdf[0]'); $im->setImageFormat('jpg'); header('Content-Type: image/jpeg'); echo ...READ MORE

Aug 14, 2020 in PHP by Niroj
• 82,880 points
4,289 views
0 votes
1 answer

How to enable PHP support in Netbeans?

Hello @kartik, Go to Tools->Plugins. In the Settings tab ensure that the ...READ MORE

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

How to order results with findBy() in Doctrine

Hii @kartik, Try out this code $ens = $em->getRepository('AcmeBinBundle:Marks')               ...READ MORE

Apr 20, 2020 in PHP by Niroj
• 82,880 points
9,242 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,709 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,819 views
0 votes
1 answer

How to get the files inside a directory?

Hello @kartik, There's a lot of ways. The ...READ MORE

Nov 9, 2020 in PHP by Niroj
• 82,880 points
344 views
0 votes
1 answer

Error:Add myBundle to the asseticBundle config symfony2 exception?

Hello @kartik, Try the below steps: edit app/config/config.yml then go to assetic: under ...READ MORE

Nov 10, 2020 in PHP by Niroj
• 82,880 points
291 views
0 votes
1 answer

In PHP, how to detect the execution is from CLI mode or through browser ?

Hello @kartik, Use the php_sapi_name() function. if (php_sapi_name() == "cli") { ...READ MORE

Oct 22, 2020 in PHP by Niroj
• 82,880 points
1,084 views
0 votes
2 answers

Error:SMTP server response: 530 SMTP authentication is required.

Yes good i like it so nice ...READ MORE

Aug 25, 2020 in PHP by Mani Usman
3,593 views
0 votes
1 answer

How do I dynamically invoke a class method in PHP?

Hello @kartik, It works both ways - you ...READ MORE

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

How to change public folder to public_html in laravel 5?

Hello, you can register the following code at Application ...READ MORE

Nov 6, 2020 in PHP by Niroj
• 82,880 points
414 views