我想使用https://pecl.php.net/package/bbcode/1.0.3b1/windows中的PECL(TS)扩展。
我在import React, {PropTypes} from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import * as actions from '../actions/fuelSavingsActions';
import FuelSavingsForm from '../components/FuelSavingsForm';
export const FuelSavingsPage = (props) => {
return (
<FuelSavingsForm
saveFuelSavings={props.actions.saveFuelSavings}
calculateFuelSavings={props.actions.calculateFuelSavings}
fuelSavings={props.fuelSavings}
/>
);
};
FuelSavingsPage.propTypes = {
actions: PropTypes.object.isRequired,
fuelSavings: PropTypes.object.isRequired
};
function mapStateToProps(state) {
return {
fuelSavings: state.fuelSavings
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators(actions, dispatch)
};
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(FuelSavingsPage);
中添加了php_bbcode.dll
,并将扩展名添加到c:/wamp/bin/php/php5.5.12/ext
中的动态扩展名列表中,并通过我得到的示例(http://imgur.com/dlWKkoW),我已经创建了自己的php.ini
BB-代码:
bb-code(PECL):
$db = mysqli_connect("localhost", "root", "password", "database") or die ("Could not connect to database");
if(isset($_POST['submit'])) {
if(isset($_POST['bio_message'])){
$BBcode = array(
'b' => array('type' => BBCODE_TYPE_NOARG, 'open_tag' => 'b', 'close_tag' => '/b'),
'i' => array('type' => BBCODE_TYPE_NOARG, 'open_tag' => 'i', 'close_tag' => '/i'),
'u' => array('type' => BBCODE_TYPE_NOARG, 'open_tag' => 'u', 'close_tag' => '/u'),
's' => array('type' => BBCODE_TYPE_NOARG, 'open_tag' => 's', 'close_tag' => '/s'),
'green' => array('type' => BBCODE_TYPE_NOARG, 'open_tag' => '<div class="green">', 'close_tag' => '</div>'),
'orange' => array('type' => BBCODE_TYPE_NOARG, 'open_tag' => '<div class="orange">', 'close_tag' => '</div>'),
'red' => array('type' => BBCODE_TYPE_NOARG, 'open_tag' => '<div class="red">', 'close_tag' => '</div>'),
'blue' => array('type' => BBCODE_TYPE_NOARG, 'open_tag' => '<div class="blue">', 'close_tag' => '</div>'),
);
$text = $_POST['bio_message'];
$BBhandler = bbcode_create($BBcode);
$htmltext = bbcode_parse($BBhandler, $text);
}
$id = htmlentities($_SESSION['user']['id'], ENT_QUOTES, 'UTF-8');
$bio_sql = "UPDATE users SET bio = '$htmltext' WHERE id = '$id'";
$db->query($bio_sql);
}else{}
但代码不会更新数据库,所以我无法测试代码是否有效。我无法在PECL bbcode上找到任何在线教程,所以我只有一张图片。