-
Notifications
You must be signed in to change notification settings - Fork 2k
Bug: Request::$uri and current_url(true) behave differently #7296
Copy link
Copy link
Closed
Labels
bugVerified issues on the current code behavior or pull requests that will fix themVerified issues on the current code behavior or pull requests that will fix them
Description
CodeIgniter Version: 4.3.2
<?php
namespace App\Controllers;
class Home extends BaseController
{
public function index()
{
$uri1 = $this->request->getUri();
var_dump($uri1);
$uri2 = current_url(true);
var_dump($uri2);
}
}1. baseURL without subfolder
From: https://forum.codeigniter.com/showthread.php?tid=86872
baseURL: http://localhost:8080/ → null
segments: [] → ['index.php']
path: / → '/index.php/'
Details
/Users/kenji/work/codeigniter/official/CodeIgniter4/app/Controllers/Home.php:10:
object(CodeIgniter\HTTP\URI)[13]
protected 'uriString' => null
private ?string 'baseURL' => string 'http://localhost:8080/' (length=22)
protected 'segments' =>
array (size=0)
empty
protected 'scheme' => string 'http' (length=4)
protected 'user' => null
protected 'password' => null
protected 'host' => string 'localhost' (length=9)
protected 'port' => int 8080
protected 'path' => string '/' (length=1)
protected 'fragment' => string '' (length=0)
protected 'query' =>
array (size=0)
empty
protected 'defaultPorts' =>
array (size=4)
'http' => int 80
'https' => int 443
'ftp' => int 21
'sftp' => int 22
protected 'showPassword' => boolean false
protected 'silent' => boolean false
protected 'rawQueryString' => boolean false
/Users/kenji/work/codeigniter/official/CodeIgniter4/app/Controllers/Home.php:13:
object(CodeIgniter\HTTP\URI)[61]
protected 'uriString' => null
private ?string 'baseURL' => null
protected 'segments' =>
array (size=1)
0 => string 'index.php' (length=9)
protected 'scheme' => string 'http' (length=4)
protected 'user' => null
protected 'password' => null
protected 'host' => string 'localhost' (length=9)
protected 'port' => int 8080
protected 'path' => string '/index.php/' (length=11)
protected 'fragment' => string '' (length=0)
protected 'query' =>
array (size=0)
empty
protected 'defaultPorts' =>
array (size=4)
'http' => int 80
'https' => int 443
'ftp' => int 21
'sftp' => int 22
protected 'showPassword' => boolean false
protected 'silent' => boolean false
protected 'rawQueryString' => boolean false
2. baseURL with subfolder
From: #7123 (comment)
baseURL: http://localhost:8888/ci432/public/ → null
segments: [] → ['ci432', 'public', 'index.php']
path: / → '/ci432/public/index.php/'
Details
/Applications/MAMP/htdocs/ci432/app/Controllers/Home.php:10:
object(CodeIgniter\HTTP\URI)[12]
protected 'uriString' => null
private ?string 'baseURL' => string 'http://localhost:8080/' (length=22)
protected 'segments' =>
array (size=0)
empty
protected 'scheme' => string 'http' (length=4)
protected 'user' => null
protected 'password' => null
protected 'host' => string 'localhost' (length=9)
protected 'port' => int 8080
protected 'path' => string '/' (length=1)
protected 'fragment' => string '' (length=0)
protected 'query' =>
array (size=0)
empty
protected 'defaultPorts' =>
array (size=4)
'http' => int 80
'https' => int 443
'ftp' => int 21
'sftp' => int 22
protected 'showPassword' => boolean false
protected 'silent' => boolean false
protected 'rawQueryString' => boolean false
/Applications/MAMP/htdocs/ci432/app/Controllers/Home.php:13:
object(CodeIgniter\HTTP\URI)[51]
protected 'uriString' => null
private ?string 'baseURL' => null
protected 'segments' =>
array (size=1)
0 => string 'index.php' (length=9)
protected 'scheme' => string 'http' (length=4)
protected 'user' => null
protected 'password' => null
protected 'host' => string 'localhost' (length=9)
protected 'port' => int 8080
protected 'path' => string '/index.php/' (length=11)
protected 'fragment' => string '' (length=0)
protected 'query' =>
array (size=0)
empty
protected 'defaultPorts' =>
array (size=4)
'http' => int 80
'https' => int 443
'ftp' => int 21
'sftp' => int 22
protected 'showPassword' => boolean false
protected 'silent' => boolean false
protected 'rawQueryString' => boolean false
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugVerified issues on the current code behavior or pull requests that will fix themVerified issues on the current code behavior or pull requests that will fix them