Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b17a50d

Browse files
Obtener parametros de la url
1 parent 1994d95 commit b17a50d

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

‎app/controllers/Home/HomeController.php

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,49 @@
55
class HomeController extends Controller
66
{
77
/**
8-
* Home controller
9-
*/
8+
* string
9+
*/
10+
public $nombre;
11+
12+
/**
13+
* array
14+
*/
15+
public $lenguajes_favoritos;
16+
17+
/**
18+
* Inicializa render
19+
*/
1020
public function __construct()
1121
{
12-
$lenguajes_favoritos = array('Javascript', 'Php');
13-
$params = array('nombre' => 'Juan', 'lenguajes' => $lenguajes_favoritos);
14-
$this->render(__CLASS__, $params);
22+
$this->nombre = 'Juan';
23+
$this->lenguajes_favoritos = array('Javascript', 'Php');
1524
}
1625

1726
/**
1827
* Método estándar
1928
*/
2029
public function exec()
2130
{
22-
31+
$this->show();
2332
}
33+
34+
/**
35+
* Método de ejemplo con parámetro
36+
*/
37+
public function show()
38+
{
39+
$params = array('nombre' => $this->nombre, 'lenguajes' => $this->lenguajes_favoritos);
40+
$this->render(__CLASS__, $params);
41+
}
42+
43+
/**
44+
* Método de ejemplo con parámetro
45+
*/
46+
public function mostrar($param)
47+
{
48+
$this->show();
49+
echo "Recibí el parámetro: {$param}";
50+
}
51+
52+
2453
}

‎index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919

2020
$controller = new $controller;
2121

22-
$controller->$method();
22+
$controller->$method($param);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /