0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHP 5.4 から、PHP 7.0 への変換スクリプト

Last updated at Posted at 2017-05-30

PHP 5.5 から、mysql_connect などが使えなくなったので、それらを、mysqli_connect に変換します。

mysql_to_php7.sh
# ! /bin/bash
#
#	mysql_to_php7.sh
#
#						May/30/2017
#
ls $1/*.php > /tmp/tmp01
awk '{print "sed -i -f sed_to_mysqli",$1}' /tmp/tmp01 > /tmp/go_tmp
#
bash /tmp/go_tmp
#
sed_to_mysqli
#
#	sed_to_mysqli
#
#				May/31/2017
#
# ---------------------------------------------------
s/mysql_connect(/$link=mysqli_connect(/g
s/mysql_select_db(/mysqli_select_db($link,/g
s/mysql_query(/mysqli_query($link,/g
s/mysql_fetch_array/mysqli_fetch_array/g
s/mysql_fetch_row/mysqli_fetch_row/g
s/mysql_fetch_assoc/mysqli_fetch_assoc/g
s/mysql_close()/mysqli_close($link)/g
s/mysql_error()/mysqli_error($link)/g
s/mysql_num_rows/mysqli_num_rows/g
s/mysql_free_result/mysqli_free_result/g
s/<? /<?php /g
# ---------------------------------------------------

使い方

./mysql_to_php7.sh フォルダー名

フォルダー内にある *.php が変換されます。

0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?