Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Thursday, June 9, 2022

Downgrade php 8.0 to 7.4

sudo yum install yum-utils -y

 1049  sudo yum-config-manager --disable remi-php5*

 1050  sudo yum-config-manager --disable remi-php80

 1051  sudo yum-config-manager --disable remi-test

 1052  sudo yum-config-manager --enable remi-php74

 1053  sudo yum remove php php-* -y   (Remove php)

 1054  sudo yum install roundcube phpmyadmin -y  (optional)






 1061  sudo dnf install php php-cli php-common

 1062  php -version

 1063  sudo service httpd restart




Wednesday, June 8, 2022

Upgrade php 7 to 8 (7.4 to 8.0)

 For Redhat(RHEL 7)  or centos 7


sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

 1001  sudo yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm

 1002  sudo yum -y install yum-utils

 1003  sudo yum-config-manager --disable 'remi-php*'


 1005  sudo dnf install php php-cli php-common

 1006  sudo yum-config-manager --disable remi-php54

 1007  sudo yum-config-manager --disable remi-php74

 1008  sudo yum-config-manager --enable remi-php80

 1009  sudo yum update

 1010  php -v


* Want to disable last remi and enable new remi

Sunday, October 2, 2016

Magento 2.0 - Display custom attribute on product listing page

In product list page you can display like this.
$attribute = $_product->getResource()->getAttribute('attribute identifier'); if ($attribute) { $brick_value = $attribute ->getFrontend()->getValue($_product); }

Tuesday, June 14, 2016

Use different PHP version CLI executable for one command

Maybe you can try to fix the environnement!
$ php -v
PHP 5.4.x (cli) ...
$ set PATH="/usr/lib64/php5.6/bin:$PATH"
$ php -v
PHP 5.6.x (cli) ...
Or, if you don't want to modify the PATH for your shell session, you can scope the change for the current command only:
$ php -v
PHP 5.4.x (cli) ...
$ env PATH="/usr/lib64/php5.6/bin:$PATH" php -v
PHP 5.6.x (cli) ...
$ php -v
PHP 5.4.x (cli) ...
If you can't change path then you can execute command as follows,(Eg: php -v)
First you want to know php-cli path
$ /php-cli-path -v

Eg:-
/usr/local/php70/bin/php-cli -v

Tuesday, May 31, 2016

How to enable extensions in PHP 7

Lets see how to enable cURL extension in PHP7


When yo update ubuntu on 16.04 or latest version then php upgrade to 6 to 7. 

Note: This guide is for those who have FULL access to the server, when system configuration can be changed. If you are using shared hosting, please contact your hosting provider.
Step 1: Check whether cURL extension is installed/enabled or not
To create a phpinfo file, open a plain text file, add the following lines, and save:
Filename: phpinfo.php
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
Visit the page in your browser. If you uploaded it to your html directory, you should now visithttp://www.example.com/phpinfo.php, replacing example.com with your own domain name.
At this point, search for the keyword “curl” and if it does not appear on the page, the extension might not be installed/enabled. Please proceed to the next step.
P.S: In this step, you are also able to locate where the “php.ini” configuration file is. Search forLoaded Configuration File” and you might end up with something like:
Step 2: Ensure cURL extension for PHP is installed
On Windows, people often use WAMP (Windows, Apache, MySQL, PHP) bundles for local development. Fortunately, cURL extension is pre-installed with those bundles, so you can proceed to Step 3.
On Linux, it depends on which Linux distro the server is installed with, so you might need to run the appropriate command.
For example, with Ubuntu/Debian server, you need to run this command:
for php7:-
sudo apt-get install php7.0-curl
After that, restart the Apache server:
sudo service apache2 restart
for php5:-
sudo apt-get install php5-curl
After that, restart the Apache server:
sudo /etc/init.d/apache2 restart
After the Apache server has restarted, the extension should be enabled by default. You might use the method at Step 1 to check, and if not, please proceed to the next step.
Step 3: Enable cURL extension in “php.ini” file
Load the “php.ini” file located in Step 1 into your favorite text editor (if you are using Windows, we suggest Notepad++), then search for “php_curl”. At this point, you need to uncomment the line by removing the semicolon at the beginning of the line, as below.
After saving the file, restart the Apache server. Go to phpinfo page again to see if the extension is enabled.
If you see something like that, then congratulations, you have successfully enabled PHP cURL!

Thursday, February 26, 2015

HOWTO: Install xdebug for PHP5

Here is a mini-howto in how to install the xdebug extension with PHP5 in Ubuntu 7.04

This will install xdebug 2.0 (or whatever is latest version in PEAR repository when you try this).

It is assumed you have Apache2 + PHP5 working already.

Code:
sudo apt-get install php5-dev php-pear
Now install xdebug thru PECL.

Code:
sudo pecl install xdebug
Now we need to find where xdebug.so went (the compiled module)

Code:
martin@martin-dev:/$ find / -name 'xdebug.so' 2> /dev/null
/usr/lib/php5/20060613/xdebug.so
Then edit php.ini:

Code:
sudo gedit /etc/php/apache2/php.ini
Add the following line:

Code:
zend_extension="/usr/lib/php5/20060613/xdebug.so"
Then restart apache for changes to take effect

Code:
sudo /etc/init.d/apache2 restart
Check phpinfo() to make sure the extension is loaded correctly. The following line should have been appended to the copyright lines:

Tuesday, June 3, 2014

Validate Email address using php built-in function

Use the filter_var() function.

A common task your web app might need to do is to check if a user has entered a valid email address. You'll no doubt find online a dizzying range of complex regular expressions that all claim to solve this problem, but the easiest way is to use PHP's built-in filter_var() function, which can validate email addresses.

Example

?
1
2
3
4
<?php
filter_var('sgamgee@example.com', FILTER_VALIDATE_EMAIL); // Returns "sgamgee@example.com". This is a valid email address.
filter_var('sauron@mordor', FILTER_VALIDATE_EMAIL); // Returns boolean false! This is *not* a valid email address.
?>

Further reading

Wednesday, January 29, 2014

How to update a JOINed tables using Codeigniter's Active Record?

Codeigniter active record doesn't allow to update a joined tables. 
After trying various method and searching the solution, I have found the following solution which does the exactly same thing i.e. update the multiple join tables. By using following method, you can update multiple table using codeigniter active record.
$this->db->set('a.firstname', 'Pekka');
$this->db->set('a.lastname', 'Kuronen');
$this->db->set('b.companyname', 'Suomi Oy');
$this->db->set('b.companyaddress', 'Mannerheimtie 123, Helsinki Suomi');

$this->db->where('a.id', 1);
$this->db->where('a.id = b.id');
$this->db->update('table as a, table2 as b');

Monday, September 30, 2013

Increase or Change the phpMyAdmin Session Timeout

Did a little grepping and found that you can override this setting, even though it’s not documented anywhere but in teh codes (so far as I can tell). To override it, just open up config.inc.php in the root phpMyAdmin directory and add this setting (anywhere):
file located 
eg:
C:\wamp\apps\phpmyadmin3.5.1\libraries\config.default.php

$cfg['LoginCookieValidity'] = <your_new_timeout>;
Where <your_new_timeout> is some number larger than 1800. Personally, I chose 28800, which is 8 hours.  :P

Tuesday, January 8, 2013

MYSQL : "THE USER SPECIFIED AS A DEFINER ('ROOT'@'%') DOES NOT EXIST"

The source code for the stored procedures that you have been loading probably contain "DEFINER=root@'%'" as part of the definition - looking a bit like this:
create definer='root'@'%' procedure sp_test() begin end;
The problem here is that you do not have an account on your system for 'root'@'%'. This can be easily demonstrated. From the MySQL command line:
show grants for 'root'@'%';
I expect that this will come back with an error message:
ERROR 1141 (42000): There is no such grant defined for user 'root' on host '%'
The fix is to alter the source of your stored procedures, or to create the missing account:
grant all on *.* to 'root'@'%' identified by 'password' with grant option;
It is not generally a good idea to have such a high-powered account accessible from anywhere, but that is another story.

Tuesday, December 25, 2012

How to remove unnessesary blank lines in your code

In Dreamviewer
  1. Open the file
  2. Click CTRL + F
  3. Select "Current document" in "Find in" (You can also select the folder if you have multiple files)
  4. Search in "Source code"
  5. Tick "Use regular expression"
  6. Type "[\r\n]{2,}" (without quotes) in "Find"
  7. Type "\n" (without quotes) in "Replace"
  8. Press "Replace All"

Friday, November 30, 2012

50 Extremely Useful PHP Tools

 50 Extremely Useful PHP Tools posted at Smashing Magazine

By Jacob Gube
PHP is one of the most widely used open-source server-side scripting languages that exist today. With over 20 million indexed domains using PHP, including major websites like Facebook, Digg and WordPress, there are good reasons why many Web developers prefer it to other server-side scripting languages, such as Python and Ruby.
PHP is faster (updated), and it is the most used scripting language in practice; it has detailed documentation, a huge community, numerous ready-to-use scripts and well-supported frameworks; and most importantly, it’s much easier to get started with PHP than with other scripting languages (Python, for example). That’s why it makes perfect sense to provide the huge community of PHP developers with an overview of useful tools and resources that can make their development process easier and more effective.
This post presents 50 useful PHP tools that can significantly improve your programming workflow. Among other things, you’ll find a plethora of libraries and classes that aid in debugging, testing, profiling and code-authoring in PHP.