Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] wartość minusowa z $_GET
SN@JPER^
post
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
 
Start new topic
Odpowiedzi (1 - 15)
com
post
Post #2





Grupa: Zarejestrowani
Postów: 3 034
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
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
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
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
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
Post #7





Grupa: Zarejestrowani
Postów: 3 034
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
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
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
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
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
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
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
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
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
Post #16





Grupa: Zarejestrowani
Postów: 3 034
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 Aktualny czas: 21.08.2025 - 21:18