「ver4/関数リファレンス/BcBaser isCurrentUrl」の版間の差分
提供: baserCMS公式ガイド
(2人の利用者による、間の4版が非表示) | |||
行3: | 行3: | ||
## 説明 | ## 説明 | ||
指定したURLが現在のURLと同じかどうか判定する。 | 指定したURLが現在のURLと同じかどうか判定する。 | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
## 使い方 | ## 使い方 | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
− | $this->BcBaser->isCurrentUrl($url) | + | <?php $this->BcBaser->isCurrentUrl($url); ?> |
</syntaxhighlight> | </syntaxhighlight> | ||
行22: | 行16: | ||
## 戻り値 | ## 戻り値 | ||
− | ( | + | (bool) |
+ | : 同じURL場合には true を返す。 | ||
行28: | 行23: | ||
### 基本 | ### 基本 | ||
− | + | 現在のページが'''/news/'''と同じか判定する。 | |
####コード | ####コード | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
− | <?php $this->BcBaser->isCurrentUrl('/news/') ?> | + | <?php |
+ | if( $this->BcBaser->isCurrentUrl('/news/') ) { | ||
+ | //true(/news/)の場合の処理 | ||
+ | } | ||
+ | ?> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | ## 注 | ||
+ | 現在のページが'''http://localhost/news/'''の場合、以下の結果となります。 | ||
− | + | isCurrentUrl('/news/')・・・`true`<br> | |
+ | isCurrentUrl('/news')・・・false<br> | ||
+ | isCurrentUrl('news')・・・false<br> | ||
+ | isCurrentUrl('/news/index')・・・`true` | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
## 変更履歴 | ## 変更履歴 | ||
行55: | 行50: | ||
## 関連資料 | ## 関連資料 | ||
[[Category:関数リファレンスver4]] | [[Category:関数リファレンスver4]] | ||
+ | |||
+ | ## 類似の関数 | ||
+ | - [isHome](/ver4/関数リファレンス/isHome) - 現在のページがトップページかどうかを判定する |
2018年12月4日 (火) 00:19時点における最新版
[このコンテンツは内容調整中です]
説明
指定したURLが現在のURLと同じかどうか判定する。
使い方
<?php $this->BcBaser->isCurrentUrl($url); ?>
パラメータ
- (string) $url
- 比較対象URL
戻り値
- (bool)
- 同じURL場合には true を返す。
用例
基本
現在のページが/news/と同じか判定する。
コード
<?php if( $this->BcBaser->isCurrentUrl('/news/') ) { //true(/news/)の場合の処理 } ?>
注
現在のページがhttp://localhost/news/の場合、以下の結果となります。
isCurrentUrl('/news/')・・・true
isCurrentUrl('/news')・・・false
isCurrentUrl('news')・・・false
isCurrentUrl('/news/index')・・・true
変更履歴
ソースファイル
関連資料
類似の関数
- isHome - 現在のページがトップページかどうかを判定する