-
Posts
15,264 -
Joined
-
Last visited
-
Days Won
431
Everything posted by requinix
-
Probably. Inheritance represents an "is a" relationship. Would it be accurate to say that your custom exception class "is an" InvalidArgumentException? If I had code that caught InvalidArgumentException, should that code also be able to catch your exception? Composition represents a "has a" relationship - or "needs a", or something else similar to that. Would it be accurate to say that your exception class "has an" InvalidArgumentException? Is your class a distinct form of exception separate, but not entirely unrelated to, an InvalidArgumentException? The answer seems like it would be the first one, however the $otherDetails is suspicious and suggests something more than an invalid argument, thus perhaps composition is more appropriate, however the fact that you chose to make it anonymous means it will be impossible to catch or type guard for that particular class in the first place, which makes composition almost useless. In other words, your example doesn't make sense. If you want a special exception class then it should be a full named class. If you want special exception data then it needs to be a full named class. And that is the real code smell.
-
How to fetch the value from stdclass object?
requinix replied to huseyinergen's topic in PHP Coding Help
Read my description of the var_dump output, then look closely at the code I posted (hint: the error message tells you exactly where to look). There was a typo. -
Software tool available to manage php website?
requinix replied to Webster_too's topic in PHP Coding Help
Most editors and IDEs will let you open an entire folder as a project and then search across all the files for something you want. If you know what the text says, or the filename of the image, then you can search for that and see where it is. -
How to fetch the value from stdclass object?
requinix replied to huseyinergen's topic in PHP Coding Help
Read my description of the var_dump output, then look closely at the code I posted (hint: the error message tells you exactly where to look). There was a typo. -
But do you actually understand why they say that? Because they are not saying that inheritance is bad. So tell me: in this situation you find yourself in, why do you feel that composition is better than inheritance?
-
How to fetch the value from stdclass object?
requinix replied to huseyinergen's topic in PHP Coding Help
object(stdClass)#12 (4) { The value you dumped is an object. ["result"]=> array(6) { It has a "result" property, which is an array. [...]=> object(stdClass)#11 (2) { Somewhere in that array (you should probably not rely on it being in a particular place) is an object. ["code"]=> string(8) "switch_1" It has a "code" property, which is a string with the value "switch_1". ["value"]=> bool(true) That same object has a "value" property, which is the boolean value true. This is an awkward structure to work with. What if you wanted other things besides the switch_1? Wouldn't it be nice if you had a single object/array that had everything at once? Try this: // assuming $object was the variable you dumped, $results = array_reduce($object->results, function($array, $result) { $array[$result->code] = $result->value; return $array; }, []); Then try dumping out $results and see if the data is easier to use in that form. -
[vscode] PHPDoc Completion
requinix replied to rick645's topic in Editor Help (PhpStorm, VS Code, etc)
That's unfortunate. Keep trying? It's not like I can log into their servers and fix it or anything. -
.obj :hover > div :hover That will target an .obj with a descendant-element you are hovering over which contains a DIV with another descendant-element you are hovering over. In other words, your HTML has to be something like <A class="obj"> <B> <div> <C> <!-- hovering here --> </C> </div> </B> </A> I doubt that's what you want. :hover isn't cinnamon, so you can't sprinkle it over miscellaneous elements and expect them to taste better. If you want the animation to play while hovering over the DIV then apply :hover directly to it alone - while also remembering that whitespace in CSS is occasionally significant. .obj > div:hover
-
Using SSL for connection to database server
requinix replied to AlphaOneIntelligence's topic in PHP Coding Help
SSL is only if you are not using a Unix socket. Which you are. So you don't need it. -
[vscode] PHPDoc Completion
requinix replied to rick645's topic in Editor Help (PhpStorm, VS Code, etc)
I don't know. Try https://community.devsense.com/ -
[vscode] PHPDoc Completion
requinix replied to rick645's topic in Editor Help (PhpStorm, VS Code, etc)
Are you using their extension? Did you turn on the appropriate settings? -
Different regular expression match result in PHP 7.4.11 and 7.4.12
requinix replied to ken678's topic in Regex Help
Most of the time, when you find an oddity like this that can't be explained any other way, the answer is going to be a JIT thing: PCRE isn't supposed to, but occasionally does behave in slightly different ways when JIT is on or off. ini_set("pcre.jit", 0); preg_match('/([^\.]|^)\s*a/', "a", $matches); But turning off JIT is not the best answer. Instead, do what kicken did and tweak the expression so it works. Anyway, that expression really should work even with JIT enabled, so feel free to file a bug report against PCRE2 about it. https://github.com/PCRE2Project/pcre2/issues -
I don't follow, partly because I don't understand what you mean by "combine" and partly because the code and samples you've posted don't fit together. You already have something that can count the number of times a "code number" is used. What does that code not do which you need?
-
Wrote php program in c drive. Not running when send to d drive
requinix replied to sonia1098's topic in PHP Coding Help
How to ask a programming question -
That's not an error. That's a link. Specifically, a link to https://goo.gl/Y0ZkNV. Pay more attention. Not if you want to do this from Javascript. But you should change to HTTPS regardless. To do it from PHP, if you can accept that you will not get an accurate location, you look up the remote IP address in some geolocation database - MaxMind's, for instance.
-
How to stop google from flagging my site as Dangerous/Fishing.
requinix replied to SiteNotWorking's topic in PHP Coding Help
If I plug your site into that reporting link I gave earlier, it says there's nothing wrong. And if I visit it in my browser, it has no complaints. Has the problem gone away? Because unless you can find out why the site is (was) marked as unsafe, it'll be hard to fix it to be safe. -
How to stop google from flagging my site as Dangerous/Fishing.
requinix replied to SiteNotWorking's topic in PHP Coding Help
Are you sure your site hasn't been compromised? Look through the files on the site and see if there are any that don't belong. -
How to stop google from flagging my site as Dangerous/Fishing.
requinix replied to SiteNotWorking's topic in PHP Coding Help
Have you tried looking into whether your assumption is correct? What do you get if you plug your site into their reporting tool? -
...you mean sorting?
-
include a php code within a forum description
requinix replied to Berserk's topic in PHP Coding Help
There are two approaches that aren't unreasonable: 1. Make your thing render as an image, and embed the image into the description (assuming it supports HTML). Then whoever sees the description will see the image. Not great for SEO or visually-impaired users. 2. Set up a cronjob that runs a script every X minutes (whatever makes sense to you). This script calculates what it needs, then goes into the database and manipulates the forum's description text. -
Congratulations: you've made this so much more complicated than it needed to be! https://stackoverflow.com/a/21064102
-
Because you tried to "get attribute" and CSS is not attributes.
-
1. Are you sure you don't mean to get the svg's width and height? Since that element actually has those two specified as attributes? 2. parentOfSVG is the same dimensions at its child. 3. getAttribute gets attributes defined on the element. You didn't define a width or height on the parent. 4. I think you want either clientWidth or offsetWidth.
-
By the way, if you ever want a submit button with a value that's separate from the label - or want a button that is more than just text - then <button> exists to help you out: <button type = "submit" name = "btnSub" value = "something" id = "zz">Select</button> where the btnSub value in $_POST will be "something".
-
I'll go ahead and say that typically one does not do that. Because the users on your site are not actually setting up a web app. When you signed up on PHPFreaks, you got an account. There's a "page" for you at https://forums.phpfreaks.com/profile/63588-i-am-obodo/ and you can create content in your personal space (so to speak). None of that came with actual system accounts. You don't have a database dedicated to you, let alone a database account. Because your ability to do those things is part of our application. You are not, in fact, setting up your own application. You're simply using ours. If you literally want people to set up applications and write code that lets them connect to databases, that's one thing. But that's not what it sounds like you're describing. What you're describing is basically like what happens on many other ecommerce sites: you sign up, you get a "store" you may or may not be able to customize (be that a URL or subdomain), and you start selling items. As a user, you don't want to spend your time dealing with databases, or installing WordPress, or updating extensions, or writing HTML, or really doing anything else except for putting items up for sale and fulfilling orders.