「ver4/関数リファレンス/BcBaser isCurrentUrl」の版間の差分
提供: baserCMS公式ガイド
行36: | 行36: | ||
現在のページが'''http://localhost/news/'''の場合、以下の結果となります。 | 現在のページが'''http://localhost/news/'''の場合、以下の結果となります。 | ||
− | isCurrentUrl('/news/') | + | isCurrentUrl('/news/')・・・`true`<br> |
isCurrentUrl('/news')・・・false<br> | isCurrentUrl('/news')・・・false<br> | ||
isCurrentUrl('news')・・・false<br> | isCurrentUrl('news')・・・false<br> | ||
− | isCurrentUrl('/news/index') | + | isCurrentUrl('/news/index')・・・`true` |
2018年12月4日 (火) 00:18時点における版
[このコンテンツは内容調整中です]
説明
指定した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