在该代码中,即使值已更改而非($content = 'europe')
更改为($content = 'asia')
,也只会执行第一个条件。剩余的条件不起作用。
function test(){
if($content = 'europe'){
$multi_tlds = $titan->getOption('wdc_europe');
} elseif($content = 'asia'){
$multi_tlds = $titan->getOption('wdc_asia');
} elseif($content = 'africa'){
$multi_tlds = $titan->getOption('wdc_africa');
}
}
请查看以下代码:
我刚刚提到了我的名字(pradeep)。这是代码的确切位置
<?php
function wdc_display_func($content){
check_ajax_referer( 'wdc_nonce', 'security' );
$titan = TitanFramework::getInstance( 'wdc-options' );
$whois = $titan->getOption( 'whois_option' );
$integration = $titan->getOption( 'integration' );
$extensions = $titan->getOption( 'extensions' );
//$multi_tlds = $titan->getOption('wdc_multi_tlds');
/*start - This is actual code (Pradeep)*/
if($content == 'europe'){
$multi_tlds = $titan->getOption('wdc_europe');
} elseif($content == 'asia'){
$multi_tlds = $titan->getOption('wdc_asia');
} elseif($content == 'africa'){
$multi_tlds = $titan->getOption('wdc_africa');
}
/* End - This is actual code (Pradeep)*/
$ext_message = $titan->getOption( 'ext_message' );
$additional_button_name = $titan->getOption( 'additional_button_name' );
$additional_button_link = $titan->getOption( 'additional_button_link' );
$custom_found_result_texts = $titan->getOption( 'custom_found_result_text' );
if($custom_found_result_texts == '') $custom_found_result_texts = __('Congratulations! {domain} is available!', 'wdc');
$custom_not_found_result_texts = $titan->getOption( 'custom_not_found_result_text' );
if($custom_not_found_result_texts == '') $custom_not_found_result_texts = __('Sorry! {domain} is already taken!', 'wdc');
if($ext_message == '') $ext_message = __('Sorry, we currently do not handle that particular tld.', 'wdc');
if(isset($_POST['domain']))
{
if($integration == 'woocommerce' OR $integration == 'custom'){
if($_POST['item_id'] != ''){
$additional_button_link = $_POST['item_id'];
}
}
$domain = str_replace(array('www.', 'http://'), NULL, $_POST['domain']);
if (strpos($domain,'.') == false) {
/*start - code (pradeep)*/
if($multi_tlds == ''){
$multi_tlds = array('com');
}else{
$multi_tlds = explode(',', $multi_tlds);
}
}else{
list($sp, $split) = explode('.', $domain,2);
$multi_tlds = array($split);
}
/*End - code (pradeep)*/
if (function_exists('idn_to_ascii')) {
$punny_domain = idn_to_ascii($domain);
}else{
$punny_domain = $domain;
$punny_domain = preg_replace("/[^-a-zA-Z0-9.]+/", "", $punny_domain);
$domain = $punny_domain;
}
$punny_domain = preg_replace("/[^-a-zA-Z0-9.]+/", "", $punny_domain);
if(strlen($punny_domain) > 0)
{
include ('lib/DomainAvailability.php');
$Domains = new DomainAvailability();
list($dom, $ext) = explode('.', $punny_domain, 2);
foreach($multi_tlds as $ex)
{
$domain = $dom.'.'.$ex;
if($extensions != ''){
$tlds = explode(',', $extensions);
if (!in_array($ex, $tlds)) {
$result = array('status'=>2,
'domain'=>$domain,
'text'=> '<div class="callout callout-warning alert-warning clearfix">
<div class="col-xs-10" style="padding-left:1px;text-align:left;">
<i class="glyphicon glyphicon-exclamation-sign" style="margin-right:1px;"></i> '.$ext_message.'
</div>
</div>
');
echo $result['text'];
wp_die();
}
}
$available = json_decode($Domains->is_available($domain));
$custom_found_result_text = str_replace( '{domain}', $domain, $custom_found_result_texts );
if($whois > 1) {
$whois_link = "<a href='".get_permalink($whois)."?&domain=$domain' target='_blank'><button id='whois' class='btn btn-danger btn-xs pull-right whois-btn'>WHOIS</button></a>";
}else{
$whois_link = '';
}
if($integration == 'whmcs'){
$check_ex = explode('.',$ex);
if(count($check_ex) == 2){
$ex_name = $check_ex[0]."_".$check_ex[1];
}else{
$ex_name = $check_ex[0];
}
$additional_button = "<a href='javascript:void(0)' onclick='submitform_$dom_$ex_name()'><button class='btn btn-success btn-xs pull-right order-btn'>$additional_button_name</button></a>";
}elseif($integration == 'woocommerce'){
//$additional_button = "<a href='?&add-to-cart=$additional_button_link&domain=$domain' target='_blank' class='btn btn-success btn-xs pull-right order-btn' >$additional_button_name</a>";
$additional_button = "<a href='http://staging1.lowcostwebagency.com/domain-contact-form/' target='_blank' class='btn btn-primary btn-xs pull-right order-btn' >Ask for</a>";
}elseif($integration == 'custom'){
if(!$additional_button_name == '' AND !$additional_button_link == ''){
$additional_button_link = str_replace( '{domain}', $domain, $additional_button_link );
$additional_button = "<a class='btn btn-success btn-xs pull-right order-btn' href='$additional_button_link'>$additional_button_name</a>";
}else{
$additional_button = '';
}
}else{
$additional_button = '';
}
$custom_not_found_result_text = str_replace( '{domain}', $domain, $custom_not_found_result_texts );
$whmcs = "<script type='text/javascript'>
function submitform_$dom_$ex_name()
{
document.whmcs_$dom_$ex_name.submit();
}
</script>
<form method='post' name='whmcs_$dom_$ex_name' id='whmcs' action='$additional_button_link/cart.php?a=add&domain=register'>
<input type='hidden' name='domains[]' value='$domain' >
<input type='hidden' name='domainsregperiod[$domain]' value='1'>
</form>";
if ($available->status == 1) {
$result = array('status'=>1,
'domain'=>$domain,
'text'=> '<div class="callout callout-success alert-success clearfix available">
<div class="col-xs-10" style="padding-left:1px;text-align:left;">
<i class="glyphicon glyphicon-ok" style="margin-right:1px;"></i> '.$custom_found_result_text.'
</div>
<div class="col-xs-2" style="padding-right:1px">'.$additional_button.' '.$whmcs.'</div>
</div>
');
echo $result['text'];
} elseif($available->status == 0) {
$result = array('status'=>0,
'domain'=>$domain,
'text'=> '<div class="callout callout-danger alert-danger clearfix not-available">
<div class="col-xs-10" style="padding-left:1px;text-align:left;">
<i class="glyphicon glyphicon-remove" style="margin-right:1px;"></i> '.$custom_not_found_result_text.'
</div>
<div class="col-xs-2" style="padding-right:1px">'.$whois_link.'</div>
</div>
');
echo $result['text'];
}elseif ($available->status == 2) {
$result = array('status'=>2,
'domain'=>$domain,
'text'=> '<div class="callout callout-warning alert-warning clearfix notfound">
<div class="col-xs-10" style="padding-left:1px;text-align:left;">
<i class="glyphicon glyphicon-exclamation-sign" style="margin-right:1px;"></i> WHOIS server not found for that TLD
</div>
</div>
');
echo $result['text'];
}
}
}
else
{
echo 'Please enter the domain name';
}
}
wp_die();
}
add_action('wp_ajax_wdc_display','wdc_display_func');
add_action('wp_ajax_nopriv_wdc_display','wdc_display_func');
function wdc_display_dashboard(){
echo do_shortcode('[wpdomainchecker]');
}
function wdc_add_dashboard_widgets() {
wp_add_dashboard_widget(
'wdc_dashboard_widget',
'WP Domain Checker',
'wdc_display_dashboard'
);
}
add_action( 'wp_dashboard_setup', 'wdc_add_dashboard_widgets' );
function wdc_whois_shortcode(){
if(isset($_GET['domain'])){
echo '<h3>Whois record for <b>'.htmlspecialchars($_GET['domain']).'</b></h3>';
require("lib/whoisClass.php");
$whois=new Whois;
echo "<pre>";
if (function_exists('idn_to_ascii')) {
echo $whois->whoislookup(idn_to_ascii($_GET['domain']));
}else{
echo $whois->whoislookup($_GET['domain']);
}
echo "</pre>";
}
}
add_shortcode( 'wpdomainwhois', 'wdc_whois_shortcode' );
function wdc_display_shortcode($atts){
$titan = TitanFramework::getInstance( 'wdc-options' );
$item_id = $titan->getOption( 'additional_button_link' );
$image = $titan->getOption( 'loading_image' );
$recaptcha_enable = $titan->getOption( 'recaptcha' );
$placeholder = $titan->getOption( 'input_placeholder' );
$image = wp_get_attachment_image_src($image);
if($image == '') {
$image = plugins_url( '/images/load.gif', __FILE__ );
}else{
$image = $image[0];
}
$atts = shortcode_atts(
array(
'width' => '900',
'button' => 'Check',
'recaptcha' => 'no',
'item_id' => $item_id,
'tld' => ''
), $atts );
if($atts['recaptcha'] == 'yes'){
$show_recaptcha = "<p> <div id='wdc-recaptcha' class='wdc' ></div></p>";
}else{
$show_recaptcha = "";
}
$content = "<div id='domain-form'>
<div id='wdc-style'>
<form method='post' action='./' id='form' class='pure-form'>
<input type='hidden' name='item_id' value='{$atts['item_id']}'>
<input type='hidden' name='tld' value='{$atts['tld']}'>
<div class='input-group' style='max-width:{$atts["width"]}px;'>
<input type='text' class='form-control' autocomplete='off' id='Search' name='domain' placeholder='$placeholder'>
<span class='input-group-btn'>
<button type='submit' id='Submit' class='btn btn-default btn-info'>{$atts["button"]}</button>
</span>
</div>
{$show_recaptcha}
<div id='loading'><img src='$image'></img></div>
<!--start - code (pradeep) -->
<div class='container'>
<div class='row'>
<div class='col-sm-3'>
<fieldset>
<input type='radio' name='asia' value='asia'> Asia<br>
<input type='radio' name='europe' value='europe'> Europe<br>
</fieldset>
</div>
<div class='col-sm-3'>
<fieldset>
<input type='radio' name='africa' value='africa'> Africa<br>
</fieldset>
</div>
</div></div>
<!-- end - code (pradeep) -->
</form>
<div style='max-width:{$atts["width"]}px;'>
<div id='results' title='API' class='result'></div>
</div>
</div>
</div>";
return $content;
}
&GT;
Remaing代码(从上面的代码继续)...如果您想要,您可以通过...我希望您可以找到解决方案:
<?php
add_shortcode( 'wpdomainchecker', 'wdc_display_shortcode' );
/* Woocommerce Function */
function custom_add_to_cart_redirect() {
if($_REQUEST['domain']){
return WC()->cart->get_cart_url();
}
}
add_filter( 'woocommerce_add_to_cart_redirect', 'custom_add_to_cart_redirect' );
function save_name_on_wdc_field( $cart_item_key, $product_id = null, $quantity= null, $variation_id= null, $variation= null ) {
WC()->session->set( $cart_item_key.'_domain', $_GET['domain'] );
WC()->session->set( $cart_item_key.'_price', $_GET['price'] );
}
add_action( 'woocommerce_add_to_cart', 'save_name_on_wdc_field', 1, 5 );
add_action( 'woocommerce_before_calculate_totals', 'add_custom_price');
function add_custom_price( $cart_object ) {
$titan = TitanFramework::getInstance( 'wdc-options' );
global $woocommerce;
$tld = array();
$extensions = $titan->getOption( 'wdc_custom_price' );
$extensions = preg_replace('/\s+/', '', $extensions);
$tlds = explode(',', $extensions);
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) {
if(WC()->session->get( $cart_item_key.'_domain')){
$domain = WC()->session->get( $cart_item_key.'_domain');
list($domain, $ext) = explode('.', $domain, 2);
foreach ($tlds as $key => $value) {
$tld = explode('|', $value);
if($ext == $tld[0]){
$price = $tld[1];
$cart_item['data']->price = $price;
}
}
}
}
}
function render_meta_on_cart_item( $title = null, $cart_item = null, $cart_item_key = null ) {
global $product_id;
if( $cart_item_key && is_cart() ) {
if(WC()->session->get( $cart_item_key.'_domain')){
echo $title. '<dl class="">
<dt class="">Domain : </dt>
<dd class=""><p>'. WC()->session->get( $cart_item_key.'_domain') .'</p></dd>
</dl>';
}else{
echo $title;
}
}else {
echo $title;
}
}
add_filter( 'woocommerce_cart_item_name', 'render_meta_on_cart_item', 1, 3 );
function render_meta_on_checkout_order_review_item( $quantity = null, $cart_item = null, $cart_item_key = null ) {
if( $cart_item_key ) {
if(WC()->session->get( $cart_item_key.'_domain')){
echo $quantity. '<dl class="">
<dt class="">Domain : </dt>
<dd class=""><p>'. WC()->session->get( $cart_item_key.'_domain') .'</p></dd>
</dl>';
}else{
echo $quantity;
}
}
}
add_filter( 'woocommerce_checkout_cart_item_quantity', 'render_meta_on_checkout_order_review_item', 1, 3 );
function wdc_order_meta_handler( $item_id, $values, $cart_item_key ) {
if(WC()->session->get( $cart_item_key.'_domain')){
wc_add_order_item_meta( $item_id, "Domain", WC()->session->get( $cart_item_key.'_domain') );
}
}
add_action( 'woocommerce_add_order_item_meta', 'wdc_order_meta_handler', 1, 3 );
function wdc_force_individual_cart_items($cart_item_data, $product_id)
{
$titan = TitanFramework::getInstance( 'wdc-options' );
$id = $titan->getOption( 'additional_button_link' );
$unique_cart_item_key = md5( microtime().rand() );
$cart_item_data['unique_key'] = $unique_cart_item_key;
return $cart_item_data;
}
add_filter( 'woocommerce_add_cart_item_data','wdc_force_individual_cart_items', 10, 2 );
add_filter('woocommerce_loop_add_to_cart_link','wdc_replace_add_to_cart');
function wdc_replace_add_to_cart() {
global $product;
$link = sprintf( '<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" data-quantity="%s" class="button product_type_%s">%s</a>',
esc_url( $product->add_to_cart_url() ),
esc_attr( $product->id ),
esc_attr( $product->get_sku() ),
esc_attr( isset( $quantity ) ? $quantity : 1 ),
esc_attr( $product->product_type ),
esc_html( $product->add_to_cart_text() )
);
$links = sprintf( '<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" data-quantity="%s" class="button product_type_%s">%s</a>',
esc_url( get_permalink($product->id) ),
esc_attr( $product->id ),
esc_attr( $product->get_sku() ),
esc_attr( isset( $quantity ) ? $quantity : 1 ),
esc_attr( $product->product_type ),
esc_html( $product->add_to_cart_text() )
);
if(get_post_meta( $product->id, 'wdc_hide_addtocart', true ) == 'yes'){
return $links;
}else{
return $link;
}
}
function wdc_remove_cart_button(){
$product_id = get_the_ID();
if(get_post_meta( $product_id, 'wdc_hide_addtocart', true ) == 'yes'){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
}
}
add_action('wp','wdc_remove_cart_button');
function wdc_woo_add_custom_general_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
woocommerce_wp_checkbox(
array(
'id' => 'wdc_hide_addtocart',
'wrapper_class' => 'wdc_item_edit_class',
'label' => __('WDC?', 'wdc' ),
'description' => __( 'Check me if you want to hide Add to Cart button on single product page.', 'wdc' )
)
);
echo '</div>';
}
function wdc_woo_add_custom_general_fields_save( $post_id ){
$woocommerce_checkbox = isset( $_POST['wdc_hide_addtocart'] ) ? 'yes' : 'no';
update_post_meta( $post_id, 'wdc_hide_addtocart', $woocommerce_checkbox );
}
// Display Fields
add_action( 'woocommerce_product_options_general_product_data', 'wdc_woo_add_custom_general_fields' );
// Save Fields
add_action( 'woocommerce_process_product_meta', 'wdc_woo_add_custom_general_fields_save' );
/* Woocommerce End Function */
function wdc_recaptcha_func() {
check_ajax_referer( 'wdc_nonce', 'security' );
if(isset($_POST['response']))
{
$titan = TitanFramework::getInstance( 'wdc-options' );
$captcha = $_POST['response'];
$secret_key = $titan->getOption( 'recaptcha_secretkey' );
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secret_key."&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
echo $response;
}
wp_die();
}
add_action('wp_ajax_wdc_recaptcha','wdc_recaptcha_func');
add_action('wp_ajax_nopriv_wdc_recaptcha','wdc_recaptcha_func');
function wdc_recaptcha_dis_func() {
check_ajax_referer( 'wdc_nonce', 'security' );
echo json_encode(array('success' => 'true'));
wp_die();
}
add_action('wp_ajax_wdc_recaptcha_dis','wdc_recaptcha_dis_func');
add_action('wp_ajax_nopriv_wdc_recaptcha_dis','wdc_recaptcha_dis_func');
function wdc_options() {
$titan = TitanFramework::getInstance( 'wdc-options' );
global $panel;
$panel = $titan->createAdminPanel( array(
'name' => 'WP Domain Checker',
'parent' => 'options-general.php',
) );
$generaltab = $panel->createTab( array(
'name' => 'General',
) );
$generaltab->createOption( array(
'name' => 'Custom Available Result Text',
'id' => 'custom_found_result_text',
'type' => 'textarea',
'desc' => 'This is custom available result text. Use {domain} to replace domain name.'
) );
$generaltab->createOption( array(
'name' => 'Custom Not Available Result Text',
'id' => 'custom_not_found_result_text',
'type' => 'textarea',
'desc' => 'This is custom not available result text. Use template tag {domain} to replace domain name.'
) );
$generaltab->createOption( array(
'name' => 'Input Placeholder',
'id' => 'input_placeholder',
'type' => 'text',
'desc' => 'Placeholder for domain input.'
) );
$generaltab->createOption( array(
'name' => 'Loading Image',
'id' => 'loading_image',
'type' => 'upload',
'desc' => 'Upload your image'
) );
$pages=get_pages( array('post_type' => 'page','post_status' => 'publish') );
foreach ($pages as $page) {
$whois_page['disable'] = 'Disable';
$whois_page[$page->ID] = $page->post_title;
}
$generaltab->createOption( array(
'name' => 'Whois Page',
'id' => 'whois_option',
'type' => 'select',
'options' => $whois_page,
'desc' => 'Enable or disable whois link if domain not available',
'default' => 'disable',
) );
$generaltab->createOption( array(
'name' => 'Integration With',
'id' => 'integration',
'type' => 'select',
'options' => array(
'disable' => 'Disable',
'whmcs' => 'WHMCS',
'woocommerce' => 'Woocommerce',
'custom' => 'Custom Link',
),
'desc' => 'Enable or disable integration.',
'default' => 'disable',
) );
$generaltab->createOption( array(
'name' => 'Integration Button Text',
'id' => 'additional_button_name',
'type' => 'text',
'desc' => 'Integration Button Text. (e.g.: "ORDER NOW")'
) );
$generaltab->createOption( array(
'name' => 'Integration Button Link',
'id' => 'additional_button_link',
'type' => 'text',
'desc' => 'Integration button link. (e.g. for WHMCS: "http://billing.host.com"). <a href="http://asdqwe.net/wordpress-plugins/wp-domain-checker-docs/" target="_blank">Documentation</a><br>
For custom link, you can use template tag {domain} to include domain in the link. <br>e.g: http://godaddy.com/?aff=12345&domain={domain}'
) );
$generaltab->createOption( array(
'name' => 'Supported TLD Extensions',
'id' => 'extensions',
'type' => 'textarea',
'desc' => 'Allow only specific extensions to check. separate by comma for each extension. (e.g: com,net,org,co.uk,co.id)<br>Leave it blank to allow all extensions.'
) );
$generaltab->createOption( array(
'name' => 'Not Supported TLD Extensions Messages',
'id' => 'ext_message',
'type' => 'text',
'desc' => 'Not Supported TLD Extensions Messages. (e.g.: "Sorry, we currently do not handle that particular tld.")'
) );
$generaltab->createOption( array(
'name' => 'WooCommerce Custom Price',
'id' => 'wdc_custom_price',
'type' => 'textarea',
'desc' => 'Allow custom price for specific tld. (e.g: com|9,net|10,org|11,co.uk|12,co.id|13)'
) );
$generaltab->createOption( array(
'name' => 'Multiple TLDs Check',
'id' => 'wdc_multi_tlds',
'type' => 'textarea',
'desc' => 'Multiple TLDs check if user not define tld on the domain. (e.g: com,net,org,info)'
) );
/*Start- code (Pradeep)*/
$generaltab->createOption( array(
'name' => 'Asia TLDs Check',
'id' => 'wdc_asia',
'type' => 'textarea',
'desc' => 'Asia TLDs check if user not define tld on the domain. (e.g: in,ch,rocks,club)'
) );
$generaltab->createOption( array(
'name' => 'Europe TLDs Check',
'id' => 'wdc_europe',
'type' => 'textarea',
'desc' => 'Europe TLDs check if user not define tld on the domain. (e.g: fr,it,pro)'
) );
$generaltab->createOption( array(
'name' => 'Africa TLDs Check',
'id' => 'wdc_africa',
'type' => 'textarea',
'desc' => 'Africa TLDs check if user not define tld on the domain. (e.g: link,af,host,me)'
) );
/*End- code (Pradeep)*/
$recaptchaTab = $panel->createTab( array(
'name' => 'reCaptcha',
) );
$panel->createOption( array(
'type' => 'save'
) );
}
add_action( 'tf_create_options', 'wdc_options' );
class wdc_widget extends WP_Widget {
function __construct() {
parent::__construct(false, $name = __('WP Domain Checker Widget'));
}
function form($instance) {
if (isset($instance['title'])) {
$title = $instance['title'];
$width = $instance['width'];
$button = $instance['button'];
$recaptcha = $instance['recaptcha'];
}else{
$title = "Domain Availability Check";
$width = "";
$button = "";
$recaptcha = "no";
}
?>
<?php
}
}
function register_wdc_widget()
{
register_widget( 'wdc_widget' );
}
add_action( 'widgets_init', 'register_wdc_widget');
?>
答案 0 :(得分:0)
这是声明变量
$content = 'europe'
应为==
$content='asia';
function test(){
if($content == 'europe'){
$multi_tlds = $titan->getOption('wdc_europe');
} elseif($content == 'asia'){
$multi_tlds = $titan->getOption('wdc_asia');
} elseif($content == 'africa'){
$multi_tlds = $titan->getOption('wdc_africa');
}
}
<input type='radio' name='asia' value='asia'> Asia<br>
<input type='radio' name='europe' value='europe'> Europe<br>
</fieldset>
</div>
<div class='col-sm-3'>
<fieldset>
<input type='radio' name='africa' value='africa'> Africa<br>
这段代码错了,它们应该都有相同的名称
name='myregionchoice'
然后你将它作为帖子处理
$regionchoice=$_POST['item_id'];
然后在if语句中
if($mygreionchoice == 'europe'){
$multi_tlds = $titan->getOption('wdc_europe');
} elseif($myregionchoice == 'asia'){
$multi_tlds = $titan->getOption('wdc_asia');
} elseif($myregionchoice == 'africa'){
$multi_tlds = $titan->getOption('wdc_africa');
}
}
使用选择选项的单选按钮,名称必须对所有人都相同 检查下面的代码,了解如何执行此操作的格式以及在页面重新加载之前和之后应处理数据的位置,并检查函数格式以及如何从函数中获取输出以及if语句必须如何测试代码工作
<html>
<head>
</head>
<body>
<form name="anyname" action="" method="post">
<input type="radio" name="choice" value="asia"/>asia
<input type="radio" name="choice" value="africa"/>africa
<input type="submit" name="submit" value="my radio choice">
</form>
<?php
function choose(){
//declare it is a global variable from outside the function
global $choice;
if ($choice =='africa') {
$test='you choose africa';
}
elseif ($choice =='asia'){
$test='you choose asia';
}
//returning the output of the function
return $test;
}
//here you proccess the data after the page reloads
if (!empty($_POST['choice'])){
$choice=$_POST["choice"];
//running the function
choose();
//getting the output from the function
$test=choose();
echo 'this is the data after the page reloads :',$test;
}
//here you process the data before the page reloads
if ((isset($_POST["submit"])) && ($_POST["submit"]!="")){
$choice=$_POST["choice"];
//running the function
choose();
//getting the output from the function
$test=choose();
}
?>
<body>
</html>
答案 1 :(得分:0)
==
用于比较,=
将变量与值等同。你需要比较内部而不是等同。
答案 2 :(得分:0)
$content = 'europe'
是一个赋值语句,它总是返回true,因此代码始终执行该条件。
我认为你所寻找的是一个比较陈述,它可能是$content == 'europe'
(和所有其他值相同)。
此外,您应该将$content
变量传递给您的函数,否则未定义:
function test($content) {...}