-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
I'd get rid of the individual public variables and use __get/set instead, with an array containing the actual values. Then it's easy: $_settings is the array and you merge the $options into it. /** * @property string $category * @property string $title * @property string $option2 * @property string $show * @property string $output */ class VarDataClass { private $settings = array( 'category' => 'DEFAULT CATEGORY', 'title' => 'DEFAULT TITLE', 'option2' => 'DEFAULT VALUE', 'show' => 'SOMETHING', 'output' => 'box' ); public function __construct(array $options = array()) { // array_intersect_key so only recognized $options get merged in $this->settings = array_merge($this->settings, array_intersect_key($options, $this->settings)); } public function __get($name) { return (isset($this->settings[$name]) ? $this->settings[$name] : null); } public function __set($name, $value) { if (isset($this->settings[$name])) { $this->settings[$name] = $value; } } }
-
Yup, that was a typo.
- 4 replies
-
- preg_match_all
- lookahead
-
(and 3 more)
Tagged with:
-
What's the code you have now? Because apparently it's sending vSubmit and vName and other vThings and the new code doesn't have those. { zProduct: zProduct, zBay: zBay, zMeasures: zMeasures, zDoor: zDoor, zPlinth: zPlinth, zMount: zMount, zBattery: zBattery}Where are all those values being defined?
-
Can you post the whole thing instead of just a couple lines?
-
is_dir Remember that $file is not the complete path so if you do is_dir($file) it will not work.
-
It is matching 10. To get that value you do $matches[1] with no more array offsets after it. Because if you do $matches[1][0] then you'll get the first character of it.
- 1 reply
-
- regex
- preg_match
-
(and 1 more)
Tagged with:
-
This is not a job for regular expressions. Read the file line by line and build up a list of serial numbers for each item. When you're done accumulating for each one (ie, when you read a new item or hit the end of the file), write the complete item back out to a new file. Or not a new file and read everything before you re-open and write.
-
Or strcasecmp.
-
Huh. It did exactly what I said it would. The .php is being added because of the first rewriting rules RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/$ $1.phpbecause "/new_folder" isn't a file. It should be ignoring directories, which you can do with RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/$ $1.php
-
Right. I put comments into the one you already had. I'm saying I don't see any opportunity for a loop. "/new_folder" will match the first set and redirect to "/new_folder.php". That then won't match any of the four sets and so... no loop. Could you just try it and see what happens?
-
I don't see how since none of the other RewriteRules will match it. # won't match because it doesn't end in a slash RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/$ $1.php # doesn't contain slash, doesn't end in a slash RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php # has a file extension RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$ RewriteRule (.*)$ /$1/ [R=301,L] # irrelevant to this discussion RewriteCond %{HTTP_HOST} !^www.example.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
-
Help for writing code without mysql_result
requinix replied to yathrakaaran's topic in PHP Coding Help
Copy and paste? Make sure the variables are using the right names. -
Put a [L,R] in each RewriteRule to see where you're being rewritten to; I think you'll end up at /new_folder.php.
-
database conncetion
requinix replied to abubaker0000's topic in Editor Help (PhpStorm, VS Code, etc)
That message has nothing to do with databases. The URL in the message 404s so it's probably wrong. Check your WAMP and DW settings to make sure they're both using the same URLs. -
Is there a way to minify javascript code in the <head>?
requinix replied to man5's topic in Javascript Help
Put all that code in a file, name the file "code.js", put it inside the /js/ folder, and then replace everything you have now with the that you want to have.- 2 replies
-
- javascript
- html
-
(and 3 more)
Tagged with:
-
Always use an absolute path. That could be with the "http://", or you could do it more easily with just "/images/abc.jpg". Try adding a DirectoryIndex index.php
-
If you want to do a prepared statement using an IN then you need placeholder for every value. You know what's easier than that? Make sure all the numbers are integers, like with an int cast or intval(), then implode() it and put it directly into the query. As long as you're definitely, definitely making things integers here then you'll be alright.
-
If you used any PHP 5.5 features then you'd probably be aware of it. More likely is a difference in the configuration between your environment and his. php.ini settings, extensions enabled, database credentials, that kind of thing. Ideally you would be testing your code in an environment that is as close to the real thing as possible - working in XAMPP and deploying to IIS (for example) is just asking for problems. Do a phpinfo() on both setups and see what the differences are.
-
New Instance of Class Rewriting Other Instance?
requinix replied to Resuwen's topic in PHP Coding Help
What you're doing wrong is making things static. Static values are the same for every single instance of the class. So don't do that. -
That's not it. The problem is that the inner function is executing after the rest of the outer function has completed. It's asynchronous. The functions will need to be restructured, probably such that the inner function submits the form (which the outer function used to do, I assume) and the outer function only validates. What's the rest of the code?
-
After match, lookbehind and get some of that too...
requinix replied to mentalist's topic in Regex Help
What about .class1 .class2 { /* used to be #000 */ color: #0f0f0f; }and .class1, .class2 { border: 1px solid #999; }What do you want to get from that? -
How about a lookbehind at the beginning that ensures there wasn't a digit before? /(?!
- 4 replies
-
- preg_match_all
- lookahead
-
(and 3 more)
Tagged with:
-
301 Redirect Using Htacess If Condition Is True
requinix replied to PHPLazy's topic in PHP Coding Help
.htaccess doesn't know about your PHP code. It would be awkward to do it there. So do the redirection in code. if ($country == "INDIA") { header("Location: http://www.new-domain.com" . $_SERVER["REQUEST_URI"], true, 301); exit; }