JQPhp is a simple and very flexible PHP library that can be used to quickly perform simple javascript calls directly via PHP.
Tired of having to include the boring <script></script> tags in the middle of your codes just because you want to do something simple such as displaying an alert or toggling the visibility of an html element?
<script>
$(document).ready(function(){ alert("This is an alert in javascript"); }); </script>
$jqphp->Alert("This is an alert in PHP");
The JQPhp
library is made of classes which are categorized into various namespaces depending on their functionality or scope.
Namespace | Location | Description |
---|---|---|
JQPhp |
JQPhp.php |
This is the base namespace and is made up of class objects that are shared among the classes of other namespaces |
JQPhp\Selector |
undefined | Contains class objects that are shared amongst the classes of every other child namespace such as JQPhp\Selector\Attributes |
JQPhp\Shared |
shared.php |
Contains objects that are required by the classes of the JQPhp\Selector namespace |
JQPhp\Selector\Attributes |
JQPhp.Selector.Attributes.php |
Contains classes that impersonates the attribute selectors as the prefix, has, contains, startswith selectors in jquery. |
JQPhp\Selector\Basics |
JQPhp.Selector.Basics.php |
the #ID, .Class, "*" (ALL) selectors are all basic selectors in jquery. This namespace contains classes that implements these selectors in PHP |
JQPhp\Selector\Filters |
JQPhp.Selector.Filters.php |
this namespace contains classes that implements the filter selectors such as :odd, :header, :even and so on in PHP. |
You can enable javascript by providing a valid url or file path location to either the minified or unminified jquery library in the constructor of this class
/* ---------- Enabling Javascript directing via PHP -----------*/ new JQPhp\Enable("path-to-jquerys-cdn-or-file-path-location.js");
This class emulates the javascript alert()
object.
/* ---------- Showing An Alert -----------*/ new JQPhp\Alert("Click The Cancel Button To Close This Alert");
This class can be used to select every element that has an attribute that contains a particular value
$prefix = new JQPhp\Prefix("a", "href", "#", new JQPhp\jquery()); /* The example above selects all"a"
element where their"href"
attributes are equivalent to"#"
*/
/* the example below selects all "div" elements where the "id" attribute is equal to "projector" */ $prefix2 = new JQPhp\Prefix("div", "id", "projector", new JQPhp\jquery());
This class and every other classes in the JQPhp\Selector\Attributes Namespace
contains three methods for changing the element, attribute or value that are declared in the constructor. The methods are: setElement($value)
, setAttribute($value)
, setValue($value)
.
Other classes in this namespace includes
StartsWith
Has
Contains
Equals
EndsWith
NotEqual
and they can all be instantiated the same way the Prefix class is instantiated
Thanks for checking out this package. Once again, I'ld love any feedbacks from you guys. I'm open to criticisms, suggestions and ready to answer your questions.