-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
Is it, though? Always a link? And always coming from your website? It's easier to just write /?, but yes. Spend some time learning about canonical URLs and what they mean to search engines. Nope. I wanted you to describe, in technical detail, exactly how mod_rewrite is going to match a URL like /shop/movies/and/more/ against your regex. To understand what it's doing and what your syntax actually translates into. True, but my point was that the category should probably just have been "movie". Right? The .+ matched everything up to the end, and not just the portion up to the next slash.
-
Pretty good, but there's a couple things I should point out: 1. You require a trailing slash at the end of the path. You should make that optional (it's not significant to the meaning of the URL) and then enforce the canonical version (presumably with a slash) in code. 2. .+ will match as much as it possibly can. What will happen if the pattern tries to match against /shop/movies/and/more/ ?
-
Spend a minute reminding yourself about how URLs work. Learn about mod_rewrite's [QSA] flag.
-
Right. The path portion identifies a particular thing. "Resource". Like the page that shows a category is a resource, and the page showing a particular product is a resource. If you want to change how that source is presented then stick it in the query string.
-
Yes. It's all much easier if you can set a pattern and use it for one specific purpose. /shop/thing browses a category, /shop/thing/thing shows an item in that category. You don't have to do any complicated logic about whether any part is a particular keyword and then have to change what the page does. Don't have to set up multiple URL rewriting rules to handle different exceptions to each pattern.
-
Yeah, it's fine.
-
Depends on the browser. I think it's common to show it when you're at the top of the page, then hide it as you scroll down. No regular user has ever cared about URLs. For a while people thought making them look fancy was important for SEO, but it isn't. Your URLs should be something that a person can look at and not be afraid of. Like this page, it says "topic" (I am viewing a topic) and it has "mod_rewrite-questions" (that's the title). That's nice and reassuring. If it was just "/viewtopic.php?tid=310679" then that's not as nice or reassuring, but neither your web server nor Google actually care.
-
What are you going to do if you need to support an item named List or Gallery? Don't mix concepts like this. It's okay to use query strings.There is absolutely nothing wrong with /shop/movies/?view=list. In fact there are some schools of thought that say the path portion indicates a resource and is not where you should be putting aspects of that resource's presentation.
-
Try it and find out? Spoiler: no Hint: []s are for individual characters. Maybe? You'll have to be more specific than that.
-
No, it is not invalid. I didn't say it was invalid. I suggested that maybe there was a better way to do what you were trying to do. Because ^(?:^)([a-zA-Z+]){2,26}(\<wbr\>\­\;)?([a-zA-Z+]){2,12}?(?:$)$ 1. You have unnecessary (?:^) and (?:$) assertions 2. You put a + in the character set, where it will mean a literal plus and not repetition 3. The parentheses for grouping around the letters do nothing 4. < > & ; are not special characters and do not need to be escaped 5. The anchors and the fact that this looks for the hyphen in a string suggests you're running this regex multiple times to add multiple hyphens? Some of those are minor flaws and some of those impact how the regex works, but mostly it just didn't feel right to me and I'm not sure that it will properly handle all the various inputs you haven't tested yet.
-
Then I'm not sure why you have this complicated scheme of checking the length of the whole string, and looking strictly at letters. Simple hyphenation is fairly simple: insert a hyphen into a word after about X characters but not within Y characters of its end. Sounds like you're going for X=10 and Y=2, so RequinixIsAregexPro hyphenates as RequinixIs-AregexPro, Ruechenseitentiere as Ruechensei-tentiere, and Ruckenseitentiere as Ruckenseit-entiere. You can adjust your X and Y to make these examples look better, but you can't set up hyphenation rules for every single word. Especially not with German. /\pL{10}(?=\pL{2})/u Find 10 letters, require that there are at least two more after it, and insert a soft hyphen. If you have to deal with HTML then sure it's a lot more complicated. You need to ignore <script>s and their contents, and ignore other tags but not their contents. Basically the only way you can do that is look letter by letter. Count out 10 letters, skipping over HTML as you go. /(\pL(?><(script).*?<\/\2>|<.*?>)*){10}(?=\pL{2})/su
-
You don't have to do everything with a regular expression. If you want to limit the length of a string, there are easier ways. What you have there is... well, I take it you've spent a lot of time throwing syntax at it until you got something that worked? Do me a favor and state the full and exact requirements for your input string and we'll see if we can't come up with something that does it all in a cleaner way.
-
How do you want to decide whether to start with "le" or "mini" or "pliable"? Randomly? Put the words into an array and use array_rand to find one. To determine a random number between 95 and 365, use rand.
-
Before dealing with this, you need to change to using prepared statements. Because as your code is now, someone could submit malicious data into your form and completely screw up everything in your database. Not sure whether you're using PDO or mysqli, but both of them support it. Switch now. It might even fix your problem, too.
-
You can't create the "map"? And the map is... what? An HTML table? An array that looks like the "matrix array" but has numbers instead of true/false? What have you done so far? What is the output you want to receive?
- 2 replies
-
- array
- while-loop
-
(and 2 more)
Tagged with:
-
HTTP/1.0? Really? That's... very surprising. Are you sure you're seeing what's really happening? The browser isn't translating anything to be "nice"? What do your server access logs show?
-
Write your own code to format the string according to the diff and invert. Not if it there was a fractional part of a day involved. It's not 2 days, it's 2-point-something days. PHP does not have a "just the date" type. There's always a time value... It's still not quite right. Check the docs for DateInterval and format to make sure you're using them correctly.
-
I didn't mean for you to throw away the code you had before... I meant, you had a specific thing that tried to read each CSV line from the line, using str_getcsv, and instead you replace that with a call to fgetcsv (plus add in fopen/fclose because you have to). Definitely keep the array_combine and whatever.
-
Oh. Well that's easy: You simply have the diff backwards. $object->diff($date) is the diff from $object to $date, and works like $date minus $object. $today->diff($tomorrow) is positive, $today->diff($yesterday) is negative.
-
That's how many people feel about it too. Personally, I use whatever is most accessible. If this is an element then I'd rather write this.value over $(this).val(). But for stuff like selectors or events? Even with document.querySelectorAll and global support for addEventListener, jQuery is still easier.
-
Looks right to me. What do you think those should be?
-
Oh dear. If you control the server then you don't need to do this. If you don't control the server then the client can just go in and remove this shackle. If the client has not paid up, don't give them control of the site. It's that simple. Wait until the contract is complete and you've received payment before handing everything over to them.
-
No surprise: you're reading the file line by line and feeding each line to str_getcsv. Switch to using fopen, fgetcsv, and fclose.
-
Yeah, it was fun times back then. They tried to get us all on one of their other forums, but... ugh. I had been on here before they shut DevShed down and I recommended it to anyone else (who cared about PHP). There are a couple other DS alumni somewhere around here, too. It's definitely good to have people maintaining the forum you use. People who actually, you know, care about it. Who aren't just letting it sit there accumulate ad revenue while running years-old software.