Latest questions in PHP

0 votes
1 answer

How to upload and Save Files with Desired name using php?

Hello, You can try this, $info = pathinfo($_FILES['userFile']['name']); $ext = ...READ MORE

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

How do I remove a directory that is not empty?

Hello, Try this code: function rrmdir($dir) { if (is_dir($dir)) { ...READ MORE

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

How to show an alert box in PHP?

Hello, use this code echo '<script language="javascript">'; echo 'alert("message successfully ...READ MORE

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

How to parse JSON and access results?

Hello, Try: $result = curl_exec($cURL); $result = json_decode($result,true); Now you can ...READ MORE

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

How to change php version in htaccess in server?

Hello, To switch to PHP 4.4: AddHandler application/x-httpd-php4 .php To ...READ MORE

Nov 4, 2020 in PHP by Niroj
• 82,880 points
2,714 views
0 votes
1 answer

How do I reload a relation collection in laravel?

You can easily tell laravel to load ...READ MORE

Nov 4, 2020 in PHP by anonymous
• 82,880 points
6,061 views
0 votes
1 answer

PHP Error: Function name must be a string

Hello @kartik, It should be $_COOKIE['name'], not $_COOKIE('name') $_COOKIE is an array, ...READ MORE

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

How do I see the actual XML generated by PHP SOAP Client Class?

Hello, Use getLastRequest. It returns the XML sent in ...READ MORE

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

How to upload and delete files from dropzone.js?

Hello, For deleting thumbnails you have to enable ...READ MORE

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

How do I receive email and process it in a web application?

Use procmail if it is installed on ...READ MORE

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

How to get the home directory from a PHP CLI script?

Hello @kartik, You can fetch the value of ...READ MORE

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

How to check if a file exists from a url using php?

Hello, You have to use CURL function does_url_exists($url) { ...READ MORE

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

How to override the path of PHP to use the MAMP path?

Hello @kartik, In your home folder /Users/David for exmaple, you ...READ MORE

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

Fatal error: Call to undefined function socket_create()

Hello @kartik, For a typical XAMPP install on ...READ MORE

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

How to check an IP address is within a range of two IPs in PHP?

Hello @kartik, With ip2long() it's easy to convert your addresses ...READ MORE

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

How to remove html special chars?

Hello, Either decode them using html_entity_decode or remove them using preg_replace: $Content ...READ MORE

Nov 3, 2020 in PHP by Niroj
• 82,880 points
2,698 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
818 views
0 votes
1 answer

How to get the base domain/url in php?

Hello @kartik, Use SERVER_NAME. echo $_SERVER['SERVER_NAME'] ...READ MORE

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

How to check if a string is an email address in PHP?

Hello, Try this without regular expressions: <?php ...READ MORE

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

Error: The mbstring extension is missing. Please check your PHP configuration

Hii, Edit the php.ini file: change extension_dir = "ext" into extension_dir = "D:\php\ext" (please write ...READ MORE

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

Error: “Input is not proper UTF-8, indicate encoding !” using PHP's simplexml_load_string

Hello, Try this: $content = utf8_encode(file_get_contents('http://example.com/rss.xml')); $xml = simplexml_load_string($content); Hope it ...READ MORE

Oct 30, 2020 in PHP by Niroj
• 82,880 points
6,170 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,226 views
0 votes
1 answer

How to generate file for download then redirect using php?

Hii, I don't think this can be done ...READ MORE

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

How to verify if $_GET exists?

You can use isset function: if(isset($_GET['id'])) { ...READ MORE

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

How to auto call function in php for every other function call?

Hii, Your best bet is the magic method __call, ...READ MORE

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

How To Execute SSH Commands Via PHP

Use phpseclib, a pure PHP, SSH implementation. An example: <?php include('Net/SSH2.php'); $ssh ...READ MORE

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

How can I enable the MySQLi extension in PHP 7?

Hello @kartik, The problem is that the package ...READ MORE

Oct 30, 2020 in PHP by Niroj
• 82,880 points
3,326 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,700 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,461 views
0 votes
1 answer

How can I replace the deprecated set_magic_quotes_runtime in php?

Hello @kartik, I used FPDF v. 1.53 and ...READ MORE

Oct 29, 2020 in PHP by Niroj
• 82,880 points
7,221 views
0 votes
1 answer

Fatal error: Call to undefined function imap_open() in PHP

Hello @kartik, In Ubuntu for install imap use sudo ...READ MORE

Oct 29, 2020 in PHP by Niroj
• 82,880 points
5,158 views
0 votes
1 answer

How to check if the request is an AJAX request with PHP?

Hello @kartik, Try below code snippet if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) ...READ MORE

Oct 29, 2020 in PHP by Niroj
• 82,880 points
11,363 views
0 votes
1 answer

How to properly indent PHP/HTML mixed code?

The PHP and the HTML should each ...READ MORE

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

How to enable curl in xampp?

Hello @kartik, You have to modify the php.ini ...READ MORE

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

How to Creat a folder when I run file_put_contents()?

Hello @kartik, file_put_contents() does not create the directory structure. ...READ MORE

Oct 29, 2020 in PHP by Niroj
• 82,880 points
3,911 views
0 votes
1 answer

How to include External CSS and JS file in Laravel?

Hello @kartik, The right way is this one: <script ...READ MORE

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

How To Run PHP From Windows Command Line in WAMPServer

Hello @kartik, Try using batch file Open notepad type php -S ...READ MORE

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

How to check if multiple array keys exists?

Hello @kartik, If you only have 2 keys ...READ MORE

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

How to create and download a csv file from php script?

Hello @kartik, You can use the built in fputcsv() for ...READ MORE

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

How to add a line break within echo in PHP?

Hello @kartik, You have to use br when ...READ MORE

Oct 27, 2020 in PHP by Niroj
• 82,880 points
2,424 views
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,857 views
0 votes
1 answer

error: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in...

Hello @kartik, Use this SQL command: ALTER USER 'mysqlUsername'@'localhost' ...READ MORE

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

How to delete all cookies of my website in php?

Hello @kartik, This will unset all of the ...READ MORE

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

How can I get the classname from a static call in an extended PHP class?

Hello @kartik, __CLASS__ always returns the name of the ...READ MORE

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

How to set upload_max_filesize in .htaccess?

Hello @kartik, php_value upload_max_filesize 30M is correct. You will have ...READ MORE

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

Catchable fatal error: Argument 1 passed to ClassA::method_a() must be an instance of ClassB, instance of ClassWrong given..

Hello @kartik, This is not a catchable fatal ...READ MORE

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

How to send email with PHPMailer - embed image in body?

Hello @kartik, I found the answer: $mail->AddEmbeddedImage('img/2u_cs_mini.jpg', 'logo_2u'); and on ...READ MORE

Oct 22, 2020 in PHP by Niroj
• 82,880 points
10,598 views