• Web Development Questions That Don't Need Their Own Thread v2
    3,079 replies, posted
[QUOTE=Dragory;33891116]Quick question. If I have something like the following: [php]class X { private $test; public function whatever() { $this->test = new Blah(); } }[/php] How would I access the variables/methods of class X from within class "Blah" that is in a variable of class X? Or is that even possible without passing class X's reference in Blah's constructor or something?[/QUOTE] $variable = new x(); $variable->whatever();
[php] class X { private $test; public function whatever() { return $this->test = new Blah(); } } class Blah { public $something = 'hello world'; } $x = new X(); echo $x->whatever()->something; [/php] That should help.
you should use return [editline]25th December 2011[/editline] my merge.
[QUOTE=zzlawlzz;33891499]$variable = new x(); $variable->whatever();[/QUOTE] That would be the variables of a [i]new[/i] class X. I need the variables of that exact class X under which the class Blah is. Sorry if I was unclear about that. [editline]25th December 2011[/editline] [QUOTE=aerochug;33891532][php] class X { private $test; public function whatever() { return $this->test = new Blah(); } } class Blah { public $something = 'hello world'; } $x = new X(); echo $x->whatever()->something; [/php] That should help.[/QUOTE] Thanks, but I seem to have been unclear about my question. I need to be able to access class X's variables [i]from[/i] class Blah (which is under the class X I need the variables from). I got it to work by passing class X's reference to class Blah's __construct, though. Just wondering if there's a better way.
The only other way I can think of is making class X extend class Blah like this: [php] class X extends Blah { // code here } [/php] Then, in class Blah you can simply type [i]parent::$var[/i] (as long as $var is protected or public, not private) or [i]parent::method()[/i] (again, only if method() is protected or public)
[QUOTE=aerochug;33892676]The only other way I can think of is making class X extend class Blah like this: [php] class X extends Blah { // code here } [/php] Then, in class Blah you can simply type [i]parent::$var[/i] (as long as $var is protected or public, not private) or [i]parent::method()[/i] (again, only if method() is protected or public)[/QUOTE] That still wouldn't access the variables of a class X I already have (only the default ones), plus it wouldn't fit in my code (I have multiple classes that need to use "class X"). But thanks anyway. [editline]25th December 2011[/editline] [QUOTE=zzlawlzz;33891535]you should use return [editline]25th December 2011[/editline] my merge.[/QUOTE] That's kind of backwards, as I need class X's variabled in class Blah, not the other way around.
[QUOTE=Dragory;33894529]That still wouldn't access the variables of a class X I already have (only the default ones), plus it wouldn't fit in my code (I have multiple classes that need to use "class X"). But thanks anyway. [editline]25th December 2011[/editline] That's kind of backwards, as I need class X's variabled in class Blah, not the other way around.[/QUOTE] I'm tired and had a bit too much martini and whathaveyou, but uh...I'm really not sure if this is what you want, but you could keep your object properties inside a protected array, using the __set and __get magic methods, and then passing that array around (which would hold the object's variables)...this can also be achieved by casting an object to an array (which should give you an array of the object's properties), and might even be a better way to achieve this... Ho ho ho.
[QUOTE=StinkyJoe;33895916]I'm tired and had a bit too much martini and whathaveyou, but uh...I'm really not sure if this is what you want, but you could keep your object properties inside a protected array, using the __set and __get magic methods, and then passing that array around (which would hold the object's variables)...this can also be achieved by casting an object to an array (which should give you an array of the object's properties), and might even be a better way to achieve this... Ho ho ho.[/QUOTE] Yeah, that could work. But I think I'll just pass a reference to the top class in the subclass' constructors and then assign that to a variable in the subclass. Seems to work so far. Cheers.
99% of the time I make my own graphics for my websites, but now I'm thinking of getting icons for my latest project. Is there any good place for simple, vector icons related to webdesign somewhere? I know I used to visit a pretty good website few years ago, but I've lost my old bookmarks. Anyone?
[url]http://webdesign.tutsplus.com/freebies/icons-freebies/exclusive-freebie-50-crisp-web-app-icons/[/url]
[QUOTE=kragmars102;33897593][url]http://webdesign.tutsplus.com/freebies/icons-freebies/exclusive-freebie-50-crisp-web-app-icons/[/url][/QUOTE] Very nice, thanks. Unfortunely, it's missing some essential icons that I need, but apart from that, it's a nice set.
Trying to remember the name of this huge vector icon pack, something in the lines of moonicons
[QUOTE=ShinyChrome;33897214]99% of the time I make my own graphics for my websites, but now I'm thinking of getting icons for my latest project. Is there any good place for simple, vector icons related to webdesign somewhere? I know I used to visit a pretty good website few years ago, but I've lost my old bookmarks. Anyone?[/QUOTE] [url]http://www.iconfinder.com/blog/7/[/url]
[QUOTE=jetboy;33899267][url]http://www.iconfinder.com/blog/7/[/url][/QUOTE] I found some good ones in there. Thanks!
is there a way soo when i over my mouse on a icon, something will popout saying, let go with a name. ex: an Steam icon that ,if you over it with your mouse, would show my steam name.
[QUOTE=mr_big90;33905775]is there a way soo when i over my mouse on a icon, something will popout saying, let go with a name. ex: an Steam icon that ,if you over it with your mouse, would show my steam name.[/QUOTE] There are various ways to achieve this, but I would put an element positioned absolutely in the icon's container (which in turn is positioned relatively), and then display it when the parent element (the icon's container) is hovered over.
nevermind that here's what i found. [html]<script type="text/javascript"> function showBox(text, obj, e) { obj.onmouseout = hideBox; obj.onmousemove = moveBox; node = document.createElement('div'); node.style.left = e.layerX + 'px'; node.style.top = e.layerY + 'px'; node.id = 'popBox'; node.innerHTML = text; obj.appendChild(node); } function moveBox(e) { node = document.getElementById('popBox'); node.style.left = e.layerX + 'px'; node.style.top = e.layerY + 'px'; } function hideBox() { node = document.getElementById('popBox'); node.parentNode.removeChild(node); } </script> <style type="text/css"> #popBox { position: absolute; z-index: 1; background: #aaaaaa; width: 73px; padding: 0.3em; border: 2px solid black; } span { color: red; font-weight: bold; } </style> </head> <body> <div onmouseover="showBox('<br /> monsieurD2', this, event)"><img src="http://filesmelt.com/dl/xboxT64.png"/></div> </body> </html>[/html] [editline]26th December 2011[/editline] [QUOTE=Dragory;33906031]There are various ways to achieve this, but I would put an element positioned absolutely in the icon's container (which in turn is positioned relatively), and then display it when the parent element (the icon's container) is hovered over.[/QUOTE] i dont know shit on html. i just copy my stuff from other poeple stuff
Don't do it with JavaScript, as that won't work for those who have it disabled. Try this: [html]<!doctype html> <html> <head> <title>--</title> <style type="text/css"> div.popup_container { position: relative; } div.popup_container:hover div.popup { /* table-cell for a box that has a changing width, block for a regular box with a defined width */ display: table-cell; } div.popup { position: absolute; display: none; /* Optional styling */ margin: 20px 0px 0px 20px; border: 1px solid #888888; background-color: #ffffff; color: #666666; border-radius: 3px; padding: 1px 3px 1px 3px; } </style> </head> <body> <div id="testElement" class="popup_container"> <div class="popup">This text is in a popup.</div> <img src="steam.png" alt="" /> </div> </body> </html>[/html]
Hi, I have a little problem again. How can one color the whole header div black and not only the background of the text. [url]http://i.imm.io/dyXw.png[/url] [CODE]div#header { background:black; color: white; font-size: 12pt; font-family:Arial,sans-serif; height:18px; margin-left:0px ; margin-bottom: 1px; padding: 0px; padding-left: 15px; }[/CODE]
[QUOTE=Dragory;33906201]Don't do it with JavaScript, as that won't work for those who have it disabled. Try this: [html]<!doctype html> <html> <head> <title>--</title> <style type="text/css"> div.popup_container { position: relative; } div.popup_container:hover div.popup { /* table-cell for a box that has a changing width, block for a regular box with a defined width */ display: table-cell; } div.popup { position: absolute; display: none; /* Optional styling */ margin: 20px 0px 0px 20px; border: 1px solid #888888; background-color: #ffffff; color: #666666; border-radius: 3px; padding: 1px 3px 1px 3px; } </style> </head> <body> <div id="testElement" class="popup_container"> <div class="popup">This text is in a popup.</div> <img src="steam.png" alt="" /> </div> </body> </html>[/html][/QUOTE] thanks, but i found out that where id like to use it, frame and java dont work. awwww. [editline]26th December 2011[/editline] but this work like a charm, you code, iv test it in a tester. [editline]26th December 2011[/editline] alternative, how does one write something under a icon? mind that i will put 7 icon next to each other. 64by64 icon that is. [editline]26th December 2011[/editline] ast one for today, can i block "movie a picture"? and saving to?
[QUOTE=ctlilc;33906406]Hi, I have a little problem again. How can one color the whole header div black and not only the background of the text. [url]http://i.imm.io/dyXw.png[/url] [CODE]div#header { background:black; color: white; font-size: 12pt; font-family:Arial,sans-serif; height:18px; margin-left:0px ; margin-bottom: 1px; padding: 0px; padding-left: 15px; }[/CODE][/QUOTE] use padding instead of margins Also [code]padding: top right bottom left;[/code]
[QUOTE=ctlilc;33906406]Hi, I have a little problem again. How can one color the whole header div black and not only the background of the text. [URL]http://i.imm.io/dyXw.png[/URL] [CODE]div#header { background:black; color: white; font-size: 12pt; font-family:Arial,sans-serif; height:18px; margin-left:0px ; margin-bottom: 1px; padding: 0px; padding-left: 15px; }[/CODE][/QUOTE] Not related to your question but use #heading and not div#heading, read this: [URL]http://css-tricks.com/efficiently-rendering-css/[/URL]
I keep getting eror 405. I have HTML form: <form action="" method="post"> and it worked on different host, now I am on blacknight host and it shows me that error. If I change index.htm to index.php it shows error 500. What to do>?
[QUOTE=arleitiss;33907345]I keep getting eror 405. I have HTML form: <form action="" method="post"> and it worked on different host, now I am on blacknight host and it shows me that error. If I change index.htm to index.php it shows error 500. What to do>?[/QUOTE] HTML code generally doesn't cause a 500 error, you have a problem with your PHP.
[code] <?php mysql_connect( "mysql1157int.cp.blacknight.com", "login", "password" ); mysql_select_db("db1197340_UsersBase"); $logged = false; $email = $_POST['email']; $firstname = $_POST['fname']; $lastname = $_POST['lname']; $nickname = $_POST['nname']; // Birthday $day = $_POST['birthday']; $month = $_POST['birthmonth']; $year = $_POST['birthyear']; $dob = $day + $month + $year; $gender = $_POST['gender']; $country = $_POST['country']; $password = $_POST['password']; $password2 = $_POST['passwordrep']; $pic = $_POST['profilepic']; if(isset($_POST['registor'])) { $query = "INSERT INTO 'Users' (email, firstname, lastname, nickname, dob, gender, country, password) VALUES( '$email', '$firstname', '$lastname', '$nickname', '$dob', '$gender', '$country', '$password')"; mysql_query($query); echo("<div id=\"shitfree\">Success! Login doesn't work yet, this is just for testing purposes stuff like dublicates works. So feel free to shit and drop here.</div>"); } ?> [/code] Whats wrong with it then?
why do you bother adding pren to echo? does it even work? [editline]26th December 2011[/editline] also, mysql escape string [editline]26th December 2011[/editline] also, i suggest using '' instead of "" when your defining things. I heard it's faster.
[QUOTE=zzlawlzz;33907680]why do you bother adding pren to echo? does it even work? [editline]26th December 2011[/editline] also, mysql escape string [editline]26th December 2011[/editline] also, i suggest using '' instead of "" when your defining things. I heard it's faster.[/QUOTE] Pren?
[QUOTE=arleitiss;33907723]Pren?[/QUOTE] ())()()()()()()()()()
[QUOTE=zzlawlzz;33907729]())()()()()()()()()()[/QUOTE] works
The server should produce an error_log for PHP errors. Also It's much easier and recommended to not echo out HTML but instead end PHP and start PHP again.
Sorry, you need to Log In to post a reply to this thread.