将PHP代码放在echo''WordPress中

时间:2016-02-15 07:19:19

标签: php wordpress

这是我的index.php。我将其打印到 <p class="welcome-block-text">Juan Aquino<br> 。我试图让它变得动态,(在我的后端更改它)但如果我粘贴第二个代码,则浏览器显示服务器错误500.

第一段代码原始代码:

 echo '<div class="row">

 if(get_option($shortname.'_custom_text_url','') != "") { 
        <p class="welcome-block-text">echo get_option($shortname.'_custom_text_url',''); <br>
 } else {
    <p class="welcome-block-text">Juan Aquiano<br>
 }

第二段代码:如何制作

UserAddedRow

3 个答案:

答案 0 :(得分:0)

以下是代码,请参阅

Route::group(['prefix'=>'admin', 'middleware'=>'auth'], function(){
    Route::get('dashboard',                             ['as'=>'user-dashboard','uses'=>'Admin\UserController@dashboard']);

    # User Role Management
    Route::group(['prefix'=>'roles', 'middleware'=>'auth'],function(){
        Route::get('show',                            ['as'=>'roles-show', 'uses'=>'Admin\RolesController@index']);
        Route::get('data',                            ['as'=>'roles-data', 'uses'=>'Admin\RolesController@getData']);
        Route::get('create',                          ['as'=>'roles-create', 'uses'=>'Admin\RolesController@create']);
        Route::post('create',                         ['as'=>'roles-store', 'uses'=>'Admin\RolesController@store']);
        Route::get('edit/{id}',                       ['as'=>'roles-edit', 'uses'=>'Admin\RolesController@edit']);
        Route::post('edit/{id}',                      ['as'=>'roles-update', 'uses'=>'Admin\RolesController@update']);
        Route::post('delete',                         ['as'=>'roles-delete', 'uses'=>'Admin\RolesController@destroy']);
    });

});

答案 1 :(得分:0)

echo '<div class="row">' . ((get_option($shortname . '_custom_text_url', '') != "") ? '<p class="welcome-block-text">' . get_option($shortname . '_custom_text_url', '') . '<br/>' : '<p class="welcome-block-text">Juan Aquiano<br>');

不要忘记关闭<p><div>

答案 2 :(得分:0)

实现这一目标的更简单方法:

<?php 
if(get_option($shortname.'_custom_text_url','') != ""){
    $p_text = get_option($shortname.'_custom_text_url','').'<br> ';
} else{
    $p_text = 'Juan Aquiano<br> ';
}
echo '<div class="row"><p class="welcome-block-text">'.$p_text.'</p></div>';
?>