logs archiveIRC Archive / Freenode / #php / 2015 / August / 3 / 1
ircfox
Hello folks!
What is wrong with this : ($a > $b ? echo "yes" : echo "no");
Could someone help me please?
teresko
that expression is made to return a value
and what it is returnning is probably "null"
all those global variables and includes make it a complete mess
eadthem
the global varables were trying to figure out why php thinks things are double defined 1 way and totaly missing another
i dont understand how php can have both senarios
teresko
eadthem: here is a free hint - never make global variables
they always are a pain to deal with
eadthem
and yet removing or adding them did nothing to help, so just ignore that there there, because there not there in the current live copy
i did not want to recommit to remove them
teresko
adlerweb: first link that you could benefit from would be: http://chadminick.com/articles/simple-php-template-engine.html
eadthem
so how can PHP possably complain it cant see varables in a included file, and then turn around and say nope you cant force it because there alredy defined.
Alphos
eadthem php will not complain about variables being already defined. not sure what's happening in your code, but that's not it
eadthem
PHP Fatal error: Cannot redeclare getPDOreadWeb() (previously declared in /srv/www/htdocs/fws/securedData.php:13) in /srv/www/htdocs/fws/securedData.php on line 14, referer: https://final.servegame.com/fws/register.php
         

ntarki
when i call session_start(), what it does to get the information from the cookie? if the cookie has expired does it create a new one?
BrianMiller
Is it okay if I compare like this? '4.2.7' < 5?
Alphos
eadthem that's not a variable. that's a function
BrianMiller !+version_compare
php-bot
BrianMiller, int version_compare(string ver1, string ver2 [, string oper]) - Compares two "PHP-standardized" version number strings - http://php.net/version_compare
teresko
BrianMiller: no, it wont work
eadthem
right but how can it complain that the function is defined twice using require and yet varables in the same file are undefined when using require once?
BrianMiller
Because I need to find if a plugin's version is older than 4.2.7 for example
teresko
eadthem: did you read the article that I linked you to ?
BrianMiller
How can I do that?
Alphos
BrianMiller in effect, it would be ok, but it's vastly preferrable to rely on version_compare for such things. 5.5 comes before 5.20 for instance, but php will consider (justly) 5.2(0) to be smaller than 5.5
eadthem
teresko i dont see a link aimed at me
Alphos
BrianMiller that's precisely what version_compare() is for
teresko
sh*t
wrong number
BrianMiller
Alphos, thank you.
teresko
eadthem: http://chadminick.com/articles/simple-php-template-engine.html
Alphos
eadthem i haven't seen your code, so there's no way for me to be sure what went wrong in it
eadthem
https://github.com/eadthem/ossmmorpg/tree/master/fws/src that is the code, specificly register.php mail.inc.php and secureData.new.php
teresko
eadthem: your code is a mess (but I think you aleardy know that). The link above should be a good first step for starting to adapt "single point of entry" approach
eadthem
im acctualy writeing a smaller test case for just this so theres less to wade thrue
teresko im not ready to move things in to templating till its further along.
teresko
eadthem: as your codebase is now, it will soon implode. You HAVE TO iterate upon it
         

eadthem
i got a idea, how bout i get it working again, then i worry about breaking it with optimisations.
teresko
ya know .. whatever
ntarki
Is it a good idea to have cookie default value at 0 or set it to 24 minutes
eadthem
better to give it a number to expire on if its security related.
if its site settings related, and abosutly not security related or auth or login, then you may want it longer.
Alphos
ntarki !+remember me
php-bot
ntarki, To let users stay logged in for longer than your PHP session lifetime: Pick a random value, save it in the user's record in your database, and give it to the user with setcookie(). Then you can later check $_COOKIE to lookup the matching user record from your db and fill in $_SESSION. For more see http://sheriframadan.com/2011/12/remember-me/
Alphos
don't expand the lifetime of your session cookie. as for general cookies, depending on your safety needs, you may wish to have them expire when the browser closes
(or not, for remember-me cookies)
ntarki
I know, I just had the handler don't read data from cookies in database older than 24 minutes but had the default setting at 0 and if the cookie was older than 24 minutes then i would get an empty session and the cookie wouldn't renew
runinsquares
just finished that SOLID video and in the Q&A at the end he seems to heavily suggest not to use abstract classes, but i got the impression he prefers them slightly over traits? Anyone else get that same impression? https://www.youtube.com/watch?v=z_LxkB-Pgf0 (roughly last two mins)
Alphos
ntarki and there's a problem with non-stale sessions ?
ntarki
I was wondering what is the best practise for 'not remember me' sessions, to expire them or leave them be until the broswer closes. I think eadthem covered me
Alphos
ntarki : it really depends on the sensibility of the cookie
some cookies can stay "indefinitely", others really shouldn't stay stored once the browser is closed
eadthem
ntarki
it doesn't give access to anything sensitive
eadthem
There was a 3rd i refrenced a lot , dont rember the link however
Alphos
eadthem : theses relate specifically to sessions and session cookies
eadthem
yes specificly that
Alphos
ntarki sessions MUST NOT remain active indefinitely
24 minutes is already plenty of time
(sorry, misread " 'not remember me' cookies" instead of "sessions")
z4c
anyone sitting on a good article about session manangement in rest apis?
Alphos
z4c i don't really see api sessions any differently than "regular" sessions, that's true of REST apis too :-/
eadthem
Any prefernce on a paticular pastebin?
runinsquares
eadthem, if you need the code to run viper-7.com or 3v4l.org are good
eadthem
it wont run, going to use my normal one some channels have specific ones they want to see used
reynir
Numline1: noob
Numline1
reynir, poopface
eadthem
Alphos
eadthem pretty much any pastebin BUT *h*astebin
i hate that they won't let me use the spacebar to scroll ^^'
eadthem
Ok there is the minimum test case, demonstrating the inclusion issue.
Alphos
eadthem ah, problem is easier to spot with an sscce
eadthem
usualy is, just ususaly lazyer to not do one :p
biberu
eadthem: it's not an inclusion issue, it's a scoping issue
Alphos
your problem stems from the fact that functions are declared earlier than variables are defined
wait, might have read that wrong, gimme a sec
eadthem
https://final.servegame.com/fwstest/
thats the running code
but of corse it wont do you much good from there :p
Alphos
the require inside your function requires a file declaring a function once that file has already been included (and the function declared) : that's a big no-no. don't mix functions and general code, and require file functions once and once only, in order to be safe
biberu
eadthem: with require_once it won't load config.php again so $yourvariables are not defined in that scope, and with requre it tries to redeclare trapFunction(), which is a fatal errorr
eadthem
yes
Alphos
yup, scope it was
eadthem
So your saying im writeing it to much like c++ and it wont work
becaus it seams a bit double standard
biberu
eadthem: if doTestFunction requires something to work you should just pass it as an argument
runinsquares
you don't need to include config.php inside the function imo
biberu
you should only rarely include things manually at all
eadthem
!?!?
biberu
denial! revelation! excitement!
eadthem
your gonna have to explain that one
biberu
which part?
eadthem
you should only rarely include things manually at all
just how is php supose to know where functions classes and etc not in the main file are at if you dont tell it?
biberu
most of your files shold be inert, only containing class defintions, and you can have those loaded automatically
eadthem
o ya ive seen the autoloader thing in ReCaptcha.php
biberu
aside from getting your enviroment running having to include files manually is almost certainly a sign of a problem
eadthem
Utter brokenness, worked right as soon as i striped it out
« prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 next »