Jump to content

Learn the languages and functions...

Programming languages aren't like "human" languages, they don't translate easily. 

I'm not very familiar with PHP but someone else here may be able to help you if you can provide the code and use. 

                     .
                   _/ V\
                  / /  /
                <<    |
                ,/    ]
              ,/      ]
            ,/        |
           /    \  \ /
          /      | | |
    ______|   __/_/| |
   /_______\______}\__}  

Spoiler

[I5-12600k | 32gb DDR5 6000 | RTX5070 | 2x1tb M.2]

 

[Ryzen 5 1600 | 16gb DDR4 3200 | GTX1030 | 4x 8tb HDD] 

 

Link to post
Share on other sites

Depending on what you have already, as in if you have a VPS or dedicated web host and if you already have PHP code already, it might just be easier to simply use python as your web server language instead of PHP. Python, last I checked was the 4th most popular web server language. If you already have a server and some php code you can still run python code. For example, a simple php file with php_exec(Your python script); can run your python code from the linux command line. Alternatively, you can use something like mod_python to embed a python interpreter inside of apache letting you run python scripts natively. Finally there are a couple of python to php coverter on github but the consensus seems to be that thy're pteey not impressive

I am good at computer

Spoiler

Motherboard: Gigabyte G1 sniper 3 | CPU: Intel 3770k @5.1Ghz | RAM: 32Gb G.Skill Ripjaws X @1600Mhz | Graphics card: EVGA 980 Ti SC | HDD: Seagate barracuda 3298534883327.74B + Samsung OEM 5400rpm drive + Seatgate barracude 2TB | PSU: Cougar CMX 1200w | CPU cooler: Custom loop

Link to post
Share on other sites

post what you have I can take a look tomorrow (uk)

 

if you have any input () in your python you will meed to create a html form to post to your php and variables start with a $ e.g $input. Other than that cant really help without seeing some code or at least pseudo code.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to post
Share on other sites

On 8/5/2016 at 9:31 PM, vorticalbox said:

post what you have I can take a look tomorrow (uk)

 

if you have any input () in your python you will meed to create a html form to post to your php and variables start with a $ e.g $input. Other than that cant really help without seeing some code or at least pseudo code.

Thanks - I can make a html form no problem, here's the code below:

 

__all__ = [ 'expressions', 'findfirsttarget', 'targetexpressions', 'strexpression' ]

sub = lambda x,y: x-y

def add(x,y):
    if x<=y: return x+y
    raise ValueError
def mul(x,y):
    if x<=y or x==1 or y==1: return x*y
    raise ValueError
def div(x,y):
    if not y or x%y or y==1:
        raise ValueError
    return x/y

add.disp = '+'
mul.disp = '*'
sub.disp = '-'
div.disp = '/'

standard_ops = [ add, sub, mul, div ]

def strexpression(e):
    if len(e)==3:
        return '('+strexpression(e[1])+e[0].disp+strexpression(e[2])+')'
    elif len(e)==1:
        return str(e[0])
    raise ValueError

def expressions(sources,ops=standard_ops,minremsources=0):
    for i in range(len(sources)):
        yield ([sources],sources[:i]+sources[i+1:],sources)
    if len(sources)>=2+minremsources:
        for e1, rs1, v1 in expressions(sources,ops,minremsources+1):
            for e2, rs2, v2 in expressions(rs1,ops,minremsources):
                for o in ops:
                    try: yield ([o,e1,e2],rs2,o(v1,v2))
                    except ValueError: pass

def targetexpressions(target,sources,ops=standard_ops):
    for e,s,v in expressions(sources,ops):
        if v==target:
            yield strexpression(e)

solver.py

Link to post
Share on other sites

I can offer some help. when you point a form to a php you can use $_GET or $_POST. post takes data posted from a form and get uses varibles in the url E.G solver.php?x=1&y=10

 

functions are like this in php, assuming you used a form to post the data, with the inputs x,y and op 

<?php
$x = $_POST['x']; #['x'] is the name of the input on the form
$y = $_POST['y'];
$op = $_POST['op'];

if($op == 'add'){
	if($x<=$y){
		print $x + $y;
	}
}else if ($op == 'mul'){
	if($x<=$y || $x == 1 || $y == 1 )
	{
		print "error";
	}else
	{
		print $x / $y;
	}
}
?>

The rest of the functions I don't understand so I will be unable to write them in PHP

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to post
Share on other sites

21 hours ago, vorticalbox said:

I can offer some help. when you point a form to a php you can use $_GET or $_POST. post takes data posted from a form and get uses varibles in the url E.G solver.php?x=1&y=10

 

functions are like this in php, assuming you used a form to post the data, with the inputs x,y and op 


<?php
$x = $_POST['x']; #['x'] is the name of the input on the form
$y = $_POST['y'];
$op = $_POST['op'];

if($op == 'add'){
	if($x<=$y){
		print $x + $y;
	}
}else if ($op == 'mul'){
	if($x<=$y || $x == 1 || $y == 1 )
	{
		print "error";
	}else
	{
		print $x / $y;
	}
}
?>

The rest of the functions I don't understand so I will be unable to write them in PHP

X and Y aren't actually inputs in this code. The input would be the array in the first line (__all__=[...]). The x and y are just within those functions.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×