Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] wartość minusowa z $_GET
SN@JPER^
post 22.04.2015, 19:52:51
Post #1





Grupa: Zarejestrowani
Postów: 266
Pomógł: 0
Dołączył: 4.01.2007
Skąd: Szczecin

Ostrzeżenie: (0%)
-----


Witam.

Nie da się odczytać wartości ujemnej z linku?

$_GET['test']=-12;

Go to the top of the page
+Quote Post
com
post 22.04.2015, 19:56:00
Post #2





Grupa: Zarejestrowani
Postów: 3 032
Pomógł: 366
Dołączył: 24.05.2012

Ostrzeżenie: (0%)
-----


czego sie ma nie dać?
http://ideone.com/WPWtD7
Go to the top of the page
+Quote Post
SN@JPER^
post 22.04.2015, 20:04:42
Post #3





Grupa: Zarejestrowani
Postów: 266
Pomógł: 0
Dołączył: 4.01.2007
Skąd: Szczecin

Ostrzeżenie: (0%)
-----


No jak się przypiszę to działa, a spróbuj pobrać z adresu.
Go to the top of the page
+Quote Post
Aqu
post 22.04.2015, 21:09:03
Post #4





Grupa: Zarejestrowani
Postów: 279
Pomógł: 58
Dołączył: 14.07.2012

Ostrzeżenie: (0%)
-----


?x=1&y=-2

  1. array (size=2)
  2. 'x' => string '1' (length=1)
  3. 'y' => string '-2' (length=2)


Co Ci nie działa? Zmienna jest pusta?
Go to the top of the page
+Quote Post
kreatiff
post 22.04.2015, 21:13:47
Post #5





Grupa: Zarejestrowani
Postów: 324
Pomógł: 105
Dołączył: 7.08.2012

Ostrzeżenie: (0%)
-----


Jedyną różncą przy przypisaniu, a pobraniu z adresu będzie ewentualnie typ zmiennej. GETy są zawsze stringami. Więc jak w przykładzie ładnie u Aqu widać, -12 nie będzie liczbą całkowitą, a właśnie ciągiem.
Go to the top of the page
+Quote Post
SN@JPER^
post 22.04.2015, 21:41:22
Post #6





Grupa: Zarejestrowani
Postów: 266
Pomógł: 0
Dołączył: 4.01.2007
Skąd: Szczecin

Ostrzeżenie: (0%)
-----


Jako pusty string pokazuje przy var_dump
Go to the top of the page
+Quote Post
com
post 22.04.2015, 22:10:22
Post #7





Grupa: Zarejestrowani
Postów: 3 032
Pomógł: 366
Dołączył: 24.05.2012

Ostrzeżenie: (0%)
-----


pokaż swój kod smile.gif
Go to the top of the page
+Quote Post
SN@JPER^
post 27.04.2015, 20:27:09
Post #8





Grupa: Zarejestrowani
Postów: 266
Pomógł: 0
Dołączył: 4.01.2007
Skąd: Szczecin

Ostrzeżenie: (0%)
-----




  1. var_dump($_GET['test']);
Go to the top of the page
+Quote Post
johny_s
post 27.04.2015, 20:36:16
Post #9





Grupa: Zarejestrowani
Postów: 594
Pomógł: 122
Dołączył: 17.07.2005
Skąd: P-na

Ostrzeżenie: (0%)
-----


zrób var_dump($_GET) w index.php czy co tam masz bez ładowania modułów, obstawiam że Twój framework coś miesza
Go to the top of the page
+Quote Post
SN@JPER^
post 27.04.2015, 20:37:27
Post #10





Grupa: Zarejestrowani
Postów: 266
Pomógł: 0
Dołączył: 4.01.2007
Skąd: Szczecin

Ostrzeżenie: (0%)
-----


array(4) { ["module"]=> string(7) "booking" ["action"]=> string(8) "calendar" ["plus"]=> string(1) "3" ["test"]=> string(0) "" }
Go to the top of the page
+Quote Post
johny_s
post 27.04.2015, 20:58:31
Post #11





Grupa: Zarejestrowani
Postów: 594
Pomógł: 122
Dołączył: 17.07.2005
Skąd: P-na

Ostrzeżenie: (0%)
-----


nie masz tam jakiegoś htacess'a po drodze albo proxy?
var_dump($_SERVER)
Go to the top of the page
+Quote Post
SN@JPER^
post 27.04.2015, 21:01:45
Post #12





Grupa: Zarejestrowani
Postów: 266
Pomógł: 0
Dołączył: 4.01.2007
Skąd: Szczecin

Ostrzeżenie: (0%)
-----


W htacessie mam taką regułę:

RewriteRule ^modules/([^-]+)/action/([^-]+) index.php?module=$1&action=$2 [L]
Go to the top of the page
+Quote Post
johny_s
post 27.04.2015, 21:07:07
Post #13





Grupa: Zarejestrowani
Postów: 594
Pomógł: 122
Dołączył: 17.07.2005
Skąd: P-na

Ostrzeżenie: (0%)
-----


[L,QSA]
Go to the top of the page
+Quote Post
SN@JPER^
post 27.04.2015, 21:21:11
Post #14





Grupa: Zarejestrowani
Postów: 266
Pomógł: 0
Dołączył: 4.01.2007
Skąd: Szczecin

Ostrzeżenie: (0%)
-----


Co zmienia QSA?

Po zmianie nadal pusto:

  1. array(4) { ["module"]=> string(7) "booking" ["action"]=> string(8) "calendar" ["plus"]=> string(1) "3" ["test"]=> string(0) "" }
Go to the top of the page
+Quote Post
Turson
post 27.04.2015, 21:31:24
Post #15





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


action/([^-]+
ta reguła wyklucza znak myślnika z parametru, a więc -x nie przejdzie

https://regex101.com/r/aP6hC0/1

// com usunąłeś posta? tongue.gif

Ten post edytował Turson 27.04.2015, 21:31:40
Go to the top of the page
+Quote Post
com
post 27.04.2015, 21:35:39
Post #16





Grupa: Zarejestrowani
Postów: 3 032
Pomógł: 366
Dołączył: 24.05.2012

Ostrzeżenie: (0%)
-----


@up, tak bo pomyliłem z ^...$ haha.gif dostanie bez minusa ale 1 mu trafi bo tam jest ([^-]+) ale to wgl ma sie nijak do problemu bo to zupełnie nie ta regułka smile.gif
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 29.03.2024 - 10:08